OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_CONTAINERS_HASH_TABLES_H_ | 5 #ifndef BASE_CONTAINERS_HASH_TABLES_H_ |
6 #define BASE_CONTAINERS_HASH_TABLES_H_ | 6 #define BASE_CONTAINERS_HASH_TABLES_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 18 matching lines...) Expand all Loading... |
29 }; | 29 }; |
30 | 30 |
31 // Use base::IntPairHash from base/hash.h as a custom hasher instead. | 31 // Use base::IntPairHash from base/hash.h as a custom hasher instead. |
32 template <typename Type1, typename Type2> | 32 template <typename Type1, typename Type2> |
33 struct hash<std::pair<Type1, Type2>> { | 33 struct hash<std::pair<Type1, Type2>> { |
34 std::size_t operator()(std::pair<Type1, Type2> value) const { | 34 std::size_t operator()(std::pair<Type1, Type2> value) const { |
35 return base::HashInts(value.first, value.second); | 35 return base::HashInts(value.first, value.second); |
36 } | 36 } |
37 }; | 37 }; |
38 | 38 |
39 } // namespace BASE_HASH_NAMESPACE | 39 } // namespace base_hash |
40 | 40 |
41 namespace base { | 41 namespace base { |
42 | 42 |
43 // Use std::unordered_map instead. | 43 // Use std::unordered_map instead. |
44 template <class Key, | 44 template <class Key, |
45 class T, | 45 class T, |
46 class Hash = BASE_HASH_NAMESPACE::hash<Key>, | 46 class Hash = BASE_HASH_NAMESPACE::hash<Key>, |
47 class Pred = std::equal_to<Key>, | 47 class Pred = std::equal_to<Key>, |
48 class Alloc = std::allocator<std::pair<const Key, T>>> | 48 class Alloc = std::allocator<std::pair<const Key, T>>> |
49 using hash_map = std::unordered_map<Key, T, Hash, Pred, Alloc>; | 49 using hash_map = std::unordered_map<Key, T, Hash, Pred, Alloc>; |
(...skipping 16 matching lines...) Expand all Loading... |
66 // Use std::unordered_set instead. | 66 // Use std::unordered_set instead. |
67 template <class Key, | 67 template <class Key, |
68 class Hash = BASE_HASH_NAMESPACE::hash<Key>, | 68 class Hash = BASE_HASH_NAMESPACE::hash<Key>, |
69 class Pred = std::equal_to<Key>, | 69 class Pred = std::equal_to<Key>, |
70 class Alloc = std::allocator<Key>> | 70 class Alloc = std::allocator<Key>> |
71 using hash_set = std::unordered_set<Key, Hash, Pred, Alloc>; | 71 using hash_set = std::unordered_set<Key, Hash, Pred, Alloc>; |
72 | 72 |
73 } // namespace base | 73 } // namespace base |
74 | 74 |
75 #endif // BASE_CONTAINERS_HASH_TABLES_H_ | 75 #endif // BASE_CONTAINERS_HASH_TABLES_H_ |
OLD | NEW |