1 #ifndef VCSN_ALGOS_SORT_HH
2 # define VCSN_ALGOS_SORT_HH
28 template <
typename Aut>
36 [&a] (transition_t l, transition_t
r)
38 return a->labelset()->less_than(a->label_of(l),
50 template <
typename Aut>
54 const auto& a = aut->as<Aut>();
70 template <
typename Aut>
93 return std::move(
res_);
99 while (!
res_->todo_.empty())
101 auto p =
res_->todo_.front();
109 std::vector<input_transition_t> ts;
114 for (
auto t:
res_->input_->all_out(s))
139 res_->new_transition_copy(res_s,
res_->state(
res_->input_->dst_of(t)),
147 for (
auto s:
res_->input_->all_states())
157 auto& aut =
res_->input_;
158 assert(aut->src_of(t1) == aut->src_of(t2));
159 if (
ls_.less_than(aut->label_of(t1), aut->label_of(t2)))
161 else if (
ls_.less_than(aut->label_of(t2), aut->label_of(t1)))
163 else if (
ws_.less_than(aut->weight_of(t1), aut->weight_of(t2)))
165 else if (
ws_.less_than(aut->weight_of(t2), aut->weight_of(t1)))
167 else if (aut->dst_of(t1) < aut->dst_of(t2))
169 else if (aut->dst_of(t2) < aut->dst_of(t1))
182 template <
typename Aut>
198 template <
typename Aut>
202 const auto& a = aut->as<Aut>();
212 #endif // !VCSN_ALGOS_SORT_HH
const labelset_t_of< input_automaton_t > & ls_
state_t_of< input_automaton_t > input_state_t
state_t_of< automaton_t > state_t
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
bool is_out_sorted(const automaton &aut)
Bridge.
void visit_successors_of_(input_state_t s, state_t res_s)
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
sorter(const input_automaton_t &a)
bool transition_less_than_(const input_transition_t t1, const input_transition_t t2) const ATTRIBUTE_PURE
A function to sort an automaton.
std::shared_ptr< detail::permutation_automaton_impl< Aut >> permutation_automaton
A permutation automaton as a shared pointer.
bool is_sorted(const Container &container, Compare comp)
auto sort(const Aut &a) -> permutation_automaton< Aut >
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
void visit_and_update_res_()
automaton sort(const automaton &aut)
Bridge.
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
transition_t_of< input_automaton_t > input_transition_t
Provide a variadic mul on top of a binary mul(), and one().
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...
permutation_automaton< input_automaton_t > automaton_t
Result automaton type.
const weightset_t_of< input_automaton_t > & ws_
Aut input_automaton_t
Input automaton type.
automaton_t res_
Sorted automaton.
variadic_mul_mixin< detail::r_impl > r
bool is_out_sorted(const Aut &a)
Whether for each state, the outgoing transitions are sorted by increasing label.
void push_inaccessible_states_()