Awali
Another Weighted Automata library
unordered_map.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_MAP_HH
18 # define AWALI_MISC_UNORDERED_MAP_HH
19 
20 # include <unordered_map>
21 
22 namespace awali {
23  namespace sttc {
24  namespace internal {
25 
27  template <typename Key, typename T,
28  typename Hash, typename KeyEqual, typename Alloc>
29  inline
30  size_t
31  collision_count(const std::unordered_map<Key, T, Hash, KeyEqual, Alloc>& m)
32  {
33  size_t res = 0;
34  for (size_t i = 0; i < m.bucket_count(); ++i)
35  res += m.bucket_size(i);
36  return res;
37  }
38 
40  template <typename Key, typename T,
41  typename Hash, typename KeyEqual, typename Alloc>
42  inline
43  bool
44  has(const std::unordered_map<Key, T, Hash, KeyEqual, Alloc>& m,
45  const Key& k)
46  {
47  return m.find(k) != std::end(m);
48  }
49 
50  }
51  }
52 }//end of ns awali::stc
53 
54 #endif // !AWALI_MISC_UNORDERED_MAP_HH
size_t collision_count(const std::unordered_map< Key, T, Hash, KeyEqual, Alloc > &m)
Sum of bucket sizes.
Definition: unordered_map.hh:31
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