5 #include <boost/range/algorithm/sort.hpp> 10 #include <vcsn/dyn/fwd.hh> 22 template <Automaton Aut>
36 const auto& llab =
aut_->label_of(l);
37 const auto& rlab =
aut_->label_of(r);
38 if (
aut_->labelset()->less(llab, rlab))
40 else if (
aut_->labelset()->less(rlab, llab))
43 return aut_->dst_of(l) <
aut_->dst_of(r);
57 template <Automaton Aut>
62 for (
auto s: a->states())
73 template <Automaton Aut>
77 const auto& a = aut->
as<Aut>();
90 template <Automaton Aut>
110 visit_and_update_res_();
111 push_inaccessible_states_();
112 visit_and_update_res_();
113 return std::move(res_);
119 while (! res_->todo_.empty())
121 auto p = res_->todo_.front();
123 visit_successors_of_(p.first, p.second);
129 std::vector<input_transition_t> ts;
134 for (
auto t:
all_out(res_->input_, s))
140 res_->new_transition_copy(res_s, res_->state(res_->input_->dst_of(t)),
148 for (
auto s: res_->input_->all_states())
159 template <Automaton Aut>
174 template <Automaton Aut>
178 const auto& a = aut->
as<Aut>();
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
transition_t_of< automaton_t > transition_t
permutation_automaton< input_automaton_t > automaton_t
Result automaton type.
typename detail::transition_t_of_impl< base_t< ValueSet > >::type transition_t_of
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
SharedPtr make_shared_ptr(Args &&... args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
auto sort(const Aut &a) -> permutation_automaton< Aut >
bool is_out_sorted(const Aut &a)
Whether for each state, the outgoing transitions are sorted by increasing label.
ATTRIBUTE_PURE bool operator()(const transition_t l, const transition_t r) const
Aut input_automaton_t
Input automaton type.
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
Provide a variadic mul on top of a binary mul(), and one().
A function to sort an automaton.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
state_t_of< automaton_t > state_t
automaton sort(const automaton &aut)
Bridge.
transition_less(const automaton_t &a)
transition_t_of< input_automaton_t > input_transition_t
automaton_t res_
Sorted automaton.
void push_inaccessible_states_()
auto & as()
Extract wrapped typed automaton.
void visit_and_update_res_()
void visit_successors_of_(input_state_t s, state_t res_s)
sorter(const input_automaton_t &a)
Compare transitions of an automaton.
Functor to compare Values of ValueSets.
bool is_sorted_forward(const Container &container, Compare comp)
Same as std::is_sorted, but works with an input iterator, not just a forward iterator.
std::shared_ptr< detail::permutation_automaton_impl< Aut > > permutation_automaton
A permutation automaton as a shared pointer.
state_t_of< input_automaton_t > input_state_t
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.