Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: base/containers/hash_tables.h

Issue 2572593002: [counting_allocator] Chrome changes.
Patch Set: Surface max_size; instrument flat_set. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/containers/flat_set.h ('k') | base/trace_event/heap_profiler_allocation_register.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
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_NAMESPACE
40 40
41 namespace base { 41 namespace base {
42 42
43 #if defined(_LIBCPP_COUNTING_ALLOCATOR)
44 #define HASH_CONTAINER_ALLOCATOR(group, type...) \
45 std::counting_allocator<type, std::allocation_group::group>
46 #else
47 #define HASH_CONTAINER_ALLOCATOR(group, type...) std::allocator<type>
48 #endif
49
43 // Use std::unordered_map instead. 50 // Use std::unordered_map instead.
44 template <class Key, 51 template <class Key,
45 class T, 52 class T,
46 class Hash = BASE_HASH_NAMESPACE::hash<Key>, 53 class Hash = BASE_HASH_NAMESPACE::hash<Key>,
47 class Pred = std::equal_to<Key>, 54 class Pred = std::equal_to<Key>,
48 class Alloc = std::allocator<std::pair<const Key, T>>> 55 class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_map, std::pair<const Key, T>)>
49 using hash_map = std::unordered_map<Key, T, Hash, Pred, Alloc>; 56 using hash_map = std::unordered_map<Key, T, Hash, Pred, Alloc>;
50 57
51 // Use std::unordered_multimap instead. 58 // Use std::unordered_multimap instead.
52 template <class Key, 59 template <class Key,
53 class T, 60 class T,
54 class Hash = BASE_HASH_NAMESPACE::hash<Key>, 61 class Hash = BASE_HASH_NAMESPACE::hash<Key>,
55 class Pred = std::equal_to<Key>, 62 class Pred = std::equal_to<Key>,
56 class Alloc = std::allocator<std::pair<const Key, T>>> 63 class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_multimap, std::pair<c onst Key, T>)>
57 using hash_multimap = std::unordered_multimap<Key, T, Hash, Pred, Alloc>; 64 using hash_multimap = std::unordered_multimap<Key, T, Hash, Pred, Alloc>;
58 65
59 // Use std::unordered_multiset instead. 66 // Use std::unordered_multiset instead.
60 template <class Key, 67 template <class Key,
61 class Hash = BASE_HASH_NAMESPACE::hash<Key>, 68 class Hash = BASE_HASH_NAMESPACE::hash<Key>,
62 class Pred = std::equal_to<Key>, 69 class Pred = std::equal_to<Key>,
63 class Alloc = std::allocator<Key>> 70 class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_multiset, Key)>
64 using hash_multiset = std::unordered_multiset<Key, Hash, Pred, Alloc>; 71 using hash_multiset = std::unordered_multiset<Key, Hash, Pred, Alloc>;
65 72
66 // Use std::unordered_set instead. 73 // Use std::unordered_set instead.
67 template <class Key, 74 template <class Key,
68 class Hash = BASE_HASH_NAMESPACE::hash<Key>, 75 class Hash = BASE_HASH_NAMESPACE::hash<Key>,
69 class Pred = std::equal_to<Key>, 76 class Pred = std::equal_to<Key>,
70 class Alloc = std::allocator<Key>> 77 class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_set, Key)>
71 using hash_set = std::unordered_set<Key, Hash, Pred, Alloc>; 78 using hash_set = std::unordered_set<Key, Hash, Pred, Alloc>;
72 79
80 #undef HASH_CONTAINER_ALLOCATOR
81
73 } // namespace base 82 } // namespace base
74 83
75 #endif // BASE_CONTAINERS_HASH_TABLES_H_ 84 #endif // BASE_CONTAINERS_HASH_TABLES_H_
OLDNEW
« no previous file with comments | « base/containers/flat_set.h ('k') | base/trace_event/heap_profiler_allocation_register.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698