8 #include <boost/bimap.hpp>
9 #include <boost/bimap/set_of.hpp>
10 #include <boost/bimap/unordered_set_of.hpp>
27 template <
typename StateNameset,
typename Stateset,
37 template <
typename StateNameset,
typename Stateset>
44 using state_t =
typename stateset_t::value_t;
52 using right_t = boost::bimaps::set_of<state_t>;
54 using bimap_t = boost::bimap<left_t, right_t>;
61 template <
typename... Args>
64 return map_.insert({ std::forward<Args>(args)... });
69 return map_.left.find(s);
74 return map_.left.end();
104 template <
typename StateNameset,
typename Stateset>
108 using state_name_t =
typename state_nameset_t::value_t;
114 vcsn::hash<state_nameset_t>,
121 template <
typename... Args>
124 return map_.emplace(std::forward<Args>(args)...);
129 return map_.find(sn);
154 if (origins_.empty())
155 for (
const auto& p: map_)
156 origins_.emplace(p.second, p.first);
168 wet_kind_t Kind = detail::wet_kind<labelset_t_of<Aut>,
181 template <
typename Ctx = context_t>
197 using state_name_t =
typename state_nameset_t::value_t;
214 ns_.new_weight(pre, input_->pre(), ws_.one());
215 todo_.push(this->emplace(std::move(pre), this->pre()).first);
217 this->set_lazy(this->pre());
223 ns_.new_weight(post, input_->post(), ws_.one());
224 this->emplace(std::move(post), this->post());
230 return has(this->origins(), s);
236 return static_if<Kind == wet_kind_t::bitset>
237 ([] (
const auto&
self) {
return state_name_t(
self.state_size_); },
238 [] (
const auto&
self) {
return self.ns_.zero(); })
244 format fmt = {},
bool delimit =
false)
const
246 const auto& origs = this->origins();
247 auto i = origs.find(s);
248 if (i == std::end(origs))
249 this->print_state(s, o);
254 ns_.print(i->second, o, fmt,
", ");
266 auto i = this->find_key(n);
267 if (i == this->end_key())
269 res = this->new_state();
272 todo_.push(this->emplace(std::move(n), res).first);
289 using queue_t = std::queue<typename state_bimap_t::const_iterator>;
295 size_t state_size_ = input_->all_states().back() + 1;
300 wet_kind_t Kind = wet_kind<labelset_t_of<Aut>,
301 weightset_t_of<Aut>>(),
307 wet_kind_t Kind = wet_kind<labelset_t_of<Aut>,
308 weightset_t_of<Aut>>(),
314 return make_shared_ptr<res_t>(aut);
weightset_t_of< automaton_t > weightset_t
typename stateset_t::value_t state_t
static const state_name_t & state_name(const const_iterator &i)
Get the state name from a const_iterator.
boost::bimap< left_t, right_t > bimap_t
Bidirectional map state_name_t -> state_t;.
static const state_name_t & state_name(const const_iterator &i)
Get the state name from a const_iterator.
auto find_key(const state_name_t &sn) const
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
StateNameset state_nameset_t
An automaton whose state names are polynomials of states.
const origins_t & origins() const
context_t_of< automaton_t > context_t
std::queue< typename state_bimap_t::const_iterator > queue_t
The sets of (input) states waiting to be processed.
typename state_nameset_t::value_t state_name_t
fresh_automaton_t_of< Aut, Ctx > fresh_automaton_t
labelset_t_of< automaton_t > labelset_t
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
An input/output format for valuesets.
Provide a variadic mul on top of a binary mul(), and one().
static state_t state(const const_iterator &i)
Get the state from a const_iterator.
auto emplace(Args &&...args)
auto emplace(Args &&...args)
const origins_t & origins() const
polystate_automaton_impl(const automaton_t &a)
Build the determinizer.
bool state_has_name(state_t s) const
std::map< state_t, state_name_t > origins_t
A map from state indexes to state names.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto make_polystate_automaton(const Aut &aut)
state_t state_(state_name_t n)
The state for set of states n.
automaton_t input_
Input automaton.
typename map_t::const_iterator const_iterator
Request the unordered_map implementation.
Aggregate an automaton, and forward calls to it.
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
auto find_key(const state_name_t &s) const
boost::bimaps::unordered_set_of< state_name_t, vcsn::hash< state_nameset_t >, vcsn::equal_to< state_nameset_t >> left_t
Storage for state names.
std::unordered_map< state_name_t, state_t, vcsn::hash< state_nameset_t >, vcsn::equal_to< state_nameset_t >> map_t
label_t_of< automaton_t > label_t
Labels and weights.
wet_kind_t
Different implementations of wets.
state_t_of< automaton_t > state_t
State index.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
auto context(Args &&...args) const -> decltype(aut_-> context(std::forward< Args >(args)...))
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
typename bimap_t::const_iterator const_iterator
static state_t state(const const_iterator &i)
Get the state from a const_iterator.
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
A bidirectional map from state names to state numbers.
This is useful to make hashes with labels or weights as keys without using non-default constructors; ...
std::shared_ptr< polystate_automaton_impl< Aut, Kind, Lazy >> polystate_automaton
A polystate automaton as a shared pointer.
boost::bimaps::set_of< state_t > right_t
Storage for state index.
std::ostream & print_state_name(state_t s, std::ostream &o, format fmt={}, bool delimit=false) const
This is useful to make hashes with labels or weights as keys without using non-default constructors; ...
StateNameset state_nameset_t
typename bimap_t::right_map origins_t
A map from state indexes to state names.
state_name_t zero() const
The empty polynomial of states.
typename stateset_t::value_t state_t