1 #ifndef VCSN_CORE_TRANSITION_MAP_HH
2 # define VCSN_CORE_TRANSITION_MAP_HH
5 # include <type_traits>
28 template <
typename Aut,
30 bool Deterministic =
false,
32 bool KeepTransitions =
false>
39 using weight_t =
typename weightset_t::value_t;
42 template <
bool KeepTransitions_ = false,
typename Dummy =
void>
56 template <
typename Dummy>
70 =
typename std::conditional<Deterministic,
72 std::vector<transition>>::type;
87 auto lb =
maps_.lower_bound(s);
88 if (lb ==
maps_.end() ||
maps_.key_comp()(s, lb->first))
95 using maps_t = std::map<state_t, map_t>;
98 template <
bool Deterministic_>
102 typename std::enable_if<Deterministic_>::type* =
nullptr)
108 template <
bool Deterministic_>
112 typename std::enable_if<!Deterministic_>::type* =
nullptr)
114 map[l].emplace_back(t);
122 auto& res =
maps_.emplace_hint(lb, s,
map_t{})->second;
123 for (
auto t:
aut_->all_out(s))
124 if (AllOut || !
aut_->labelset()->is_special(
aut_->label_of(t)))
126 auto w =
ws_.conv(*
aut_->weightset(),
aut_->weight_of(t));
127 insert_<Deterministic>(res,
144 #endif // !VCSN_CORE_TRANSITION_MAP_HH
weight_t wgt
The (converted) weight.
transition_t_of< Aut > transition
transition_(weight_t w, state_t d, transition_t)
void insert_(map_t &map, label_t_of< Aut > l, transition t, typename std::enable_if<!Deterministic_ >::type *=nullptr)
Insert l -> t in map.
transition_t_of< automaton_t > transition_t
typename weightset_t::value_t weight_t
std::map< label_t_of< automaton_t >, transitions_t > map_t
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.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
Outgoing signature: weight, destination.
void insert_(map_t &map, label_t_of< Aut > l, transition t, typename std::enable_if< Deterministic_ >::type *=nullptr)
Insert l -> t in map.
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
map_t & operator[](state_t s)
Outgoing transitions of state s, sorted by label.
transition_map(const Aut &aut, const weightset_t &ws)
const weightset_t & ws_
The result weightset.
typename std::conditional< Deterministic, transition, std::vector< transition >>::type transitions_t
weight_t wgt
The (converted) weight.
transition_map(const Aut &aut)
map_t & build_map_(typename maps_t::iterator lb, state_t s)
Build and return the transition map for state s, store at res.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
state_t_of< automaton_t > state_t
std::map< state_t, map_t > maps_t
weightset_t_of< automaton_t > weightset_t
const Aut & aut_
The automaton whose transitions are cached.
transition_< KeepTransitions > transition
Outgoing signature: weight, destination, and possibly transition identifier.
Cache the outgoing transitions of an automaton as efficient maps label -> vector<(weight, dst)>.