| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |