17 #ifndef AWALI_CORE_TRANSITION_MAP_HH
18 # define AWALI_CORE_TRANSITION_MAP_HH
21 # include <type_traits>
23 namespace awali {
namespace sttc {
41 template <
typename Aut,
42 typename WeightSet = weightset_t_of<Aut>,
43 bool Deterministic =
false,
48 using weight_t =
typename weightset_t::value_t;
57 =
typename std::conditional<Deterministic,
59 std::vector<transition>>::type;
61 using maps_t = std::map<state_t, map_t>;
74 template <
bool Deterministic_>
78 typename std::enable_if<Deterministic_>::type* =
nullptr)
84 template <
bool Deterministic_>
88 typename std::enable_if<!Deterministic_>::type* =
nullptr)
90 map[l].emplace_back(t);
98 auto& res =
maps_.emplace_hint(lb, s,
map_t{})->second;
99 for (
auto t:
aut_->all_out(s))
100 if (AllOut || !
aut_->labelset()->is_special(
aut_->label_of(t)))
102 auto w =
ws_.conv(*
aut_->weightset(),
aut_->weight_of(t));
103 insert_<Deterministic>(res,
112 auto lb =
maps_.lower_bound(s);
113 if (lb ==
maps_.end() ||
maps_.key_comp()(s, lb->first))
weightset_description weightset(const std::string &k)
auto map(const std::tuple< Ts... > &ts, Fun f) -> decltype(map_tuple_(f, ts, make_index_sequence< sizeof...(Ts)>()))
Map a function on a tuple, return tuple of the results.
Definition: tuple.hh:134
typename internal::label_t_of_impl< internal::base_t< ValueSet > >::type label_t_of
Helper to retrieve the type of the labels of a value set.
Definition: traits.hh:71
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21
Cache the outgoing transitions of an automaton as efficient maps label -> vector<(weight,...
Definition: transition_map.hh:46
typename std::conditional< Deterministic, transition, std::vector< transition > >::type transitions_t
Definition: transition_map.hh:59
map_t & operator[](state_t s)
Definition: transition_map.hh:110
transition_map(const Aut &aut, const weightset_t &ws)
Definition: transition_map.hh:64
const Aut & aut_
The automaton whose transitions are cached.
Definition: transition_map.hh:120
transition_map(const Aut &aut)
Definition: transition_map.hh:69
WeightSet weightset_t
Definition: transition_map.hh:47
void insert_(map_t &map, label_t_of< Aut > l, transition t, typename std::enable_if< Deterministic_ >::type *=nullptr)
Insert l -> t in map.
Definition: transition_map.hh:76
std::map< label_t_of< Aut >, transitions_t > map_t
Definition: transition_map.hh:60
maps_t maps_
Definition: transition_map.hh:62
void insert_(map_t &map, label_t_of< Aut > l, transition t, typename std::enable_if<!Deterministic_ >::type *=nullptr)
Insert l -> t in map.
Definition: transition_map.hh:86
map_t & build_map_(typename maps_t::iterator lb, state_t s)
Build and return the transition map for state s, store at res.
Definition: transition_map.hh:96
std::map< state_t, map_t > maps_t
Definition: transition_map.hh:61
typename weightset_t::value_t weight_t
Definition: transition_map.hh:48
const weightset_t & ws_
The result weightset.
Definition: transition_map.hh:122
weight_t wgt
The (converted) weight.
Definition: transition_map.hh:52
state_t dst
Definition: transition_map.hh:53
Definition: transition_map.hh:50