3 #include <boost/bimap.hpp> 4 #include <boost/bimap/set_of.hpp> 5 #include <boost/bimap/unordered_set_of.hpp> 21 template <
typename StateNameset,
typename Stateset,
31 template <
typename StateNameset,
typename Stateset>
39 using state_t =
typename stateset_t::value_t;
47 using right_t = boost::bimaps::set_of<state_t>;
49 using bimap_t = boost::bimap<left_t, right_t>;
56 template <
typename... Args>
59 return map_.insert({ std::forward<Args>(args)... });
64 return map_.left.find(s);
69 return map_.left.end();
102 template <
typename StateNameset,
typename Stateset>
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);
boost::bimap< left_t, right_t > bimap_t
Bidirectional map state_name_t -> state_t;.
StateNameset state_nameset_t
typename map_t::const_iterator const_iterator
const origins_t & origins() const
typename stateset_t::value_t state_t
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.
static state_t state(const const_iterator &i)
Get the state from a const_iterator.
auto emplace(Args &&... args)
Insert a new state.
boost::bimaps::set_of< state_t > right_t
Storage for state index.
This is useful to make hashes with labels or weights as keys without using non-default constructors; ...
std::map< state_t, state_name_t > origins_t
A map from state indexes to state names.
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 &s) const
typename state_nameset_t::value_t state_name_t
auto emplace(Args &&... args)
Insert a new state.
auto find_key(const state_name_t &sn) const
A bidirectional map from state names to state numbers.
static state_t state(const const_iterator &i)
Get the state from a const_iterator.
StateNameset state_nameset_t
This is useful to make hashes with labels or weights as keys without using non-default constructors; ...
const origins_t & origins() const
typename stateset_t::value_t state_t
std::unordered_map< state_name_t, state_t, vcsn::hash< state_nameset_t >, vcsn::equal_to< state_nameset_t > > map_t
Request the unordered_map implementation.
typename bimap_t::right_map origins_t
A map from state indexes to state names.
typename bimap_t::const_iterator const_iterator
typename state_nameset_t::value_t state_name_t
static const state_name_t & state_name(const const_iterator &i)
Get the state name from a const_iterator.