OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 V8_ZONE_CONTAINERS_H_ | 5 #ifndef V8_ZONE_CONTAINERS_H_ |
6 #define V8_ZONE_CONTAINERS_H_ | 6 #define V8_ZONE_CONTAINERS_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 template <typename K, typename V, typename Compare = std::less<K>> | 115 template <typename K, typename V, typename Compare = std::less<K>> |
116 class ZoneMap | 116 class ZoneMap |
117 : public std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>> { | 117 : public std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>> { |
118 public: | 118 public: |
119 // Constructs an empty map. | 119 // Constructs an empty map. |
120 explicit ZoneMap(Zone* zone) | 120 explicit ZoneMap(Zone* zone) |
121 : std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>>( | 121 : std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>>( |
122 Compare(), zone_allocator<std::pair<const K, V>>(zone)) {} | 122 Compare(), zone_allocator<std::pair<const K, V>>(zone)) {} |
123 }; | 123 }; |
124 | 124 |
| 125 // A wrapper subclass for std::multimap to make it easy to construct one that |
| 126 // uses a zone allocator. |
| 127 template <typename K, typename V, typename Compare = std::less<K>> |
| 128 class ZoneMultimap |
| 129 : public std::multimap<K, V, Compare, |
| 130 zone_allocator<std::pair<const K, V>>> { |
| 131 public: |
| 132 // Constructs an empty multimap. |
| 133 explicit ZoneMultimap(Zone* zone) |
| 134 : std::multimap<K, V, Compare, zone_allocator<std::pair<const K, V>>>( |
| 135 Compare(), zone_allocator<std::pair<const K, V>>(zone)) {} |
| 136 }; |
125 | 137 |
126 // Typedefs to shorten commonly used vectors. | 138 // Typedefs to shorten commonly used vectors. |
127 typedef ZoneVector<bool> BoolVector; | 139 typedef ZoneVector<bool> BoolVector; |
128 typedef ZoneVector<int> IntVector; | 140 typedef ZoneVector<int> IntVector; |
129 | 141 |
130 } // namespace internal | 142 } // namespace internal |
131 } // namespace v8 | 143 } // namespace v8 |
132 | 144 |
133 #endif // V8_ZONE_CONTAINERS_H_ | 145 #endif // V8_ZONE_CONTAINERS_H_ |
OLD | NEW |