Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
map.hh
Go to the documentation of this file.
1 #ifndef VCSN_MISC_MAP_HH
2 # define VCSN_MISC_MAP_HH
3 
4 # include <map>
5 # include <vcsn/misc/hash.hh>
6 
7 namespace std
8 {
9 
10  /*------------------------.
11  | hash(map<Key, Value>). |
12  `------------------------*/
13 
14  template <typename Key, typename Value, typename Compare, typename Alloc>
15  struct hash<map<Key, Value, Compare, Alloc>>
16  {
17  size_t operator()(const map<Key, Value, Compare, Alloc>& m) const
18  {
19  size_t res = 0;
20  for (const auto& kv: m)
21  {
22  hash_combine(res, kv.first);
23  hash_combine(res, kv.second);
24  }
25  return res;
26  }
27  };
28 }
29 
30 namespace vcsn
31 {
32  template <typename Key, typename Value, typename Compare, typename Alloc>
33  inline
34  bool
35  has(const std::map<Key, Value, Compare, Alloc>& s, const Key& e)
36  {
37  return s.find(e) != std::end(s);
38  }
39 
40  template <typename ValueSet>
41  class less : public std::less<typename ValueSet::value_t>
42  {
43  public:
44  using valueset_t = ValueSet;
45  using value_t = typename valueset_t::value_t;
46 
47  bool operator()(const value_t& lhs, const value_t& rhs) const
48  {
49  return valueset_t::less_than(lhs, rhs);
50  }
51  };
52 
53 }
54 
55 #endif // !VCSN_MISC_MAP_HH
size_t operator()(const map< Key, Value, Compare, Alloc > &m) const
Definition: map.hh:17
auto map(const std::tuple< Ts...> &ts, Fun f) -> decltype(map_tuple_(f, ts, make_index_sequence< sizeof...(Ts)>()))
Map a function on a tuple, return tuple of the results.
Definition: tuple.hh:101
typename valueset_t::value_t value_t
Definition: map.hh:45
bool operator()(const value_t &lhs, const value_t &rhs) const
Definition: map.hh:47
RatExpSet::value_t less_than(const RatExpSet &rs, const typename RatExpSet::value_t &v)
Definition: less-than.hh:150
ValueSet valueset_t
Definition: map.hh:44
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
Definition: map.hh:35