5 #include <unordered_map>
18 template <Automaton Aut>
19 class permutation_automaton_impl
20 :
public automaton_decorator<fresh_automaton_t_of<Aut>>
27 template <
typename Ctx = context_t>
49 static auto res =
symbol{
"permutation_automaton<"
56 o <<
"permutation_automaton<";
61 bool state_has_name(state_t) const
67 print_state_name(state_t s, std::ostream& o,
69 bool delimit = false) const
71 return input_->print_state_name(origins().at(s), o, fmt, delimit);
77 // Benches show that the map_.emplace technique is slower, and
78 // then that operator[] is faster than emplace.
80 auto i = map_.find(s);
81 if (i == std::end(map_))
83 res = super_t::new_state();
93 using origins_t = std::map<state_t, state_name_t>;
100 for (const auto& p: map_)
101 origins_[p.second] = p.first;
105 using pair_t = std::pair<state_name_t, state_t>;
106 std::queue<pair_t> todo_;
109 std::unordered_map<state_name_t, state_t> map_;
111 mutable origins_t origins_;
114 const automaton_t input_;
116 } // namespace detail
fresh_automaton_t_of< automaton_t, Ctx > fresh_automaton_t
Generated automaton type.
std::unordered_map< state_name_t, state_t > map_
Input-state -> sorted-state.
static constexpr auto pre(Args &&...args) -> decltype(element_type::pre(std::forward< Args >(args)...))
std::ostream & print_set(std::ostream &o, format fmt={}) const
Aggregate an automaton, and forward calls to it.
An input/output format for valuesets.
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
const automaton_t input_
Input automaton.
static constexpr auto post(Args &&...args) -> decltype(element_type::post(std::forward< Args >(args)...))
Aut automaton_t
Input automaton type.
static symbol sname()
Static name.
permutation_automaton_impl(const automaton_t &input)
AutOut make_fresh_automaton(const AutIn &model)
Create an empty, mutable, automaton, based on another one.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
state_t_of< automaton_t > state_name_t
Symbolic state name: input automaton state type.
context_t_of< automaton_t > context_t
state_t_of< fresh_automaton_t<>> state_t
Sorted automaton state type.
std::queue< pair_t > todo_
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of