1 #ifndef VCSN_ALGOS_FILTER_HH
2 # define VCSN_ALGOS_FILTER_HH
5 # include <boost/range/irange.hpp>
18 template <
typename Aut>
47 ss_.emplace(input->pre());
48 ss_.emplace(input->post());
58 std::string
vname(
bool full =
true)
const
60 return "filter_automaton<" +
aut_->vname(full) +
">";
66 return aut_->state_has_name(s);
75 const std::string& fmt =
"text",
76 bool delimit =
false)
const
79 return aut_->print_state_name(s, o, fmt, delimit);
92 template <
typename Pred>
96 {
return pred(s) &&
has(
ss_, s); });
111 return std::max(
pre(),
post()) < s;
115 template <
typename Pred>
146 template <
typename Pred>
150 return aut_->all_out(s,
180 return aut_.labelset()->equal(
aut_->label_of(t, l));
184 template <
typename Pred>
188 return aut_->all_in(s,
217 return (
aut_.labelset()->equal(
aut_->label_of(t), l));
221 typename automaton_t::element_type::automaton_nocv_t
251 template <
typename Aut>
253 std::shared_ptr<detail::filter_automaton_impl<Aut>>;
256 template <
typename Aut>
261 return make_shared_ptr<filter_automaton<Aut>>(aut, ss);
269 template <
typename Aut,
typename Un
signeds>
273 const auto& a = aut->as<Aut>();
274 std::unordered_set<state_t_of<Aut>> ss;
283 const std::vector<unsigned>& ss) ->
automaton);
container_filter_range< const tr_cont_t & > in(state_t s, const label_t &l) const
super_t::transitions_output_t all_transitions() const
All the transition indexes between all states (including pre and post).
states_output_t states() const
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
container_filter_range< const tr_cont_t & > all_out(state_t s, Pred pred) const
container_filter_range< const tr_cont_t & > out(state_t s, const label_t &l) const
label_t_of< automaton_t > label_t
states_output_t all_states(Pred pred) const
static std::string sname()
Static name.
states_output_t all_states() const
container_filter_range< const tr_cont_t & > out(state_t s) const
super_t::transitions_output_t transitions() const
All the transition indexes between visible states.
auto dst_of(Args &&...args) const -> decltype(aut_-> dst_of(std::forward< Args >(args)...))
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
container_filter_range< const tr_cont_t & > all_in(state_t s, Pred pred) const
bool has_state(state_t s) const
super_t::transitions_output_t all_transitions(Pred pred) const
states_t ss_
The states we keep.
AutOut copy(const AutIn &input, Pred keep_state)
A copy of input keeping only its states that are accepted by keep_state.
bool state_has_name(state_t s) const
Aggregate an automaton, and forward calls to it.
automaton filter(const automaton &aut, const std::vector< unsigned > &states)
Bridge.
Hide some states of an automaton.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
automaton_t::element_type::automaton_nocv_t strip() const
container_filter_range< const tr_cont_t & > in(state_t s) const
std::string vname(bool full=true) const
Dynamic name.
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
container_filter_range< const tr_cont_t & > initial_transitions() const
Indexes of transitions to visible initial states.
state_t_of< automaton_t > state_t
typename Aut::element_type::transitions_output_t transitions_output_t
std::unordered_set< state_t > states_t
States set that we want to filter.
transition_t_of< automaton_t > transition_t
auto src_of(Args &&...args) const -> decltype(aut_-> src_of(std::forward< Args >(args)...))
std::vector< transition_t > tr_cont_t
static constexpr auto pre(Args &&...args) -> decltype(automaton_t::element_type::pre(std::forward< Args >(args)...))
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
std::ostream & print_state_name(state_t s, std::ostream &o, const std::string &fmt="text", bool delimit=false) const
container_filter_range< const tr_cont_t & > all_out(state_t s) const
std::shared_ptr< detail::filter_automaton_impl< Aut >> filter_automaton
container_filter_range< const tr_cont_t & > all_in(state_t s) const
container_filter_range< const tr_cont_t & > final_transitions() const
Indexes of transitions from visible final states.
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
static constexpr auto post(Args &&...args) -> decltype(automaton_t::element_type::post(std::forward< Args >(args)...))
automaton_t aut_
The wrapped automaton, possibly const.
filter_automaton< Aut > filter(const Aut &aut, const std::unordered_set< state_t_of< Aut >> &ss)
Get an automaton who is a part state set ss of aut.
filter_automaton_impl(const automaton_t &input, const states_t &ss)