Awali
Another Weighted Automata library
unordered_set.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_MISC_UNORDERED_SET_HH
18 # define AWALI_MISC_UNORDERED_SET_HH
19 
20 # include <unordered_set>
21 
22 #include <awali/utils/hash.hh>
23 
24 namespace std
25 {
26 
27  /*-------------------------.
28  | hash(unordered_set<T>). |
29  `-------------------------*/
30 
31  template <typename T>
32  struct hash<unordered_set<T>>
33  {
34  size_t operator()(const unordered_set<T>& ss) const
35  {
36  std::hash<T> hasher;
37  size_t res = 0;
38  for (auto s: ss)
39  res += hasher(s);
40  return res;
41  }
42  };
43 }
44 
45 namespace awali {
46  namespace sttc {
47  namespace internal {
48 
50  template <typename Key, typename Hash, typename KeyEqual, typename Alloc>
51  bool
52  has(const std::unordered_set<Key, Hash, KeyEqual, Alloc>& s, const Key& k)
53  {
54  return s.find(k) != std::end(s);
55  }
56  }
57  }
58 }//end of ns awali::stc
59 
60 #endif // !AWALI_MISC_UNORDERED_SET_HH
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
Definition: map.hh:53
Main namespace of Awali.
Definition: ato.hh:22
size_t operator()(const unordered_set< T > &ss) const
Definition: unordered_set.hh:34