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

Side by Side Diff: base/containers/flat_set.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/allocator/allocator_shim_override_cpp_symbols.h ('k') | base/containers/hash_tables.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_FLAT_SET_H_ 5 #ifndef BASE_CONTAINERS_FLAT_SET_H_
6 #define BASE_CONTAINERS_FLAT_SET_H_ 6 #define BASE_CONTAINERS_FLAT_SET_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <functional> 9 #include <functional>
10 #include <utility> 10 #include <utility>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // but it seems to be a quadratic algorithm. For now we do not implement this 78 // but it seems to be a quadratic algorithm. For now we do not implement this
79 // method. 79 // method.
80 // TODO(dyaroshev): research an algorithm for range insertion crbug.com/682249. 80 // TODO(dyaroshev): research an algorithm for range insertion crbug.com/682249.
81 81
82 template <class Key, class Compare = std::less<Key>> 82 template <class Key, class Compare = std::less<Key>>
83 // Meets the requirements of Container, AssociativeContainer, 83 // Meets the requirements of Container, AssociativeContainer,
84 // ReversibleContainer. 84 // ReversibleContainer.
85 // Requires: Key is Movable, Compare is a StrictWeakOrdering on Key. 85 // Requires: Key is Movable, Compare is a StrictWeakOrdering on Key.
86 class flat_set { 86 class flat_set {
87 private: 87 private:
88 using underlying_type = std::vector<Key>; 88 using underlying_type = std::vector<Key, std::counting_allocator<Key, std::all ocation_group::base_flat_set>>;
89 89
90 public: 90 public:
91 // -------------------------------------------------------------------------- 91 // --------------------------------------------------------------------------
92 // Types. 92 // Types.
93 // 93 //
94 using key_type = Key; 94 using key_type = Key;
95 using key_compare = Compare; 95 using key_compare = Compare;
96 using value_type = Key; 96 using value_type = Key;
97 using value_compare = Compare; 97 using value_compare = Compare;
98 98
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // Erases all elements that match predicate. It has O(size) complexity. 663 // Erases all elements that match predicate. It has O(size) complexity.
664 template <typename Key, typename Compare, typename Predicate> 664 template <typename Key, typename Compare, typename Predicate>
665 void EraseIf(base::flat_set<Key, Compare>& container, Predicate pred) { 665 void EraseIf(base::flat_set<Key, Compare>& container, Predicate pred) {
666 container.erase(std::remove_if(container.begin(), container.end(), pred), 666 container.erase(std::remove_if(container.begin(), container.end(), pred),
667 container.end()); 667 container.end());
668 } 668 }
669 669
670 } // namespace base 670 } // namespace base
671 671
672 #endif // BASE_CONTAINERS_FLAT_SET_H_ 672 #endif // BASE_CONTAINERS_FLAT_SET_H_
OLDNEW
« no previous file with comments | « base/allocator/allocator_shim_override_cpp_symbols.h ('k') | base/containers/hash_tables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698