| 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_SRC_ZONE_ZONE_CONTAINERS_H_ | 5 #ifndef V8_SRC_ZONE_ZONE_CONTAINERS_H_ |
| 6 #define V8_SRC_ZONE_ZONE_CONTAINERS_H_ | 6 #define V8_SRC_ZONE_ZONE_CONTAINERS_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // Constructs a new vector and fills it with {size} elements, each | 30 // Constructs a new vector and fills it with {size} elements, each |
| 31 // constructed via the default constructor. | 31 // constructed via the default constructor. |
| 32 ZoneVector(size_t size, Zone* zone) | 32 ZoneVector(size_t size, Zone* zone) |
| 33 : std::vector<T, zone_allocator<T>>(size, T(), zone_allocator<T>(zone)) {} | 33 : std::vector<T, zone_allocator<T>>(size, T(), zone_allocator<T>(zone)) {} |
| 34 | 34 |
| 35 // Constructs a new vector and fills it with {size} elements, each | 35 // Constructs a new vector and fills it with {size} elements, each |
| 36 // having the value {def}. | 36 // having the value {def}. |
| 37 ZoneVector(size_t size, T def, Zone* zone) | 37 ZoneVector(size_t size, T def, Zone* zone) |
| 38 : std::vector<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {} | 38 : std::vector<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {} |
| 39 |
| 40 // Constructs a new vector and fills it with the contents of the range |
| 41 // [first, last). |
| 42 template <class InputIt> |
| 43 ZoneVector(InputIt first, InputIt last, Zone* zone) |
| 44 : std::vector<T, zone_allocator<T>>(first, last, |
| 45 zone_allocator<T>(zone)) {} |
| 39 }; | 46 }; |
| 40 | 47 |
| 41 // A wrapper subclass std::deque to make it easy to construct one | 48 // A wrapper subclass std::deque to make it easy to construct one |
| 42 // that uses a zone allocator. | 49 // that uses a zone allocator. |
| 43 template <typename T> | 50 template <typename T> |
| 44 class ZoneDeque : public std::deque<T, zone_allocator<T>> { | 51 class ZoneDeque : public std::deque<T, zone_allocator<T>> { |
| 45 public: | 52 public: |
| 46 // Constructs an empty deque. | 53 // Constructs an empty deque. |
| 47 explicit ZoneDeque(Zone* zone) | 54 explicit ZoneDeque(Zone* zone) |
| 48 : std::deque<T, zone_allocator<T>>(zone_allocator<T>(zone)) {} | 55 : std::deque<T, zone_allocator<T>>(zone_allocator<T>(zone)) {} |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 }; | 136 }; |
| 130 | 137 |
| 131 // Typedefs to shorten commonly used vectors. | 138 // Typedefs to shorten commonly used vectors. |
| 132 typedef ZoneVector<bool> BoolVector; | 139 typedef ZoneVector<bool> BoolVector; |
| 133 typedef ZoneVector<int> IntVector; | 140 typedef ZoneVector<int> IntVector; |
| 134 | 141 |
| 135 } // namespace internal | 142 } // namespace internal |
| 136 } // namespace v8 | 143 } // namespace v8 |
| 137 | 144 |
| 138 #endif // V8_SRC_ZONE_ZONE_CONTAINERS_H_ | 145 #endif // V8_SRC_ZONE_ZONE_CONTAINERS_H_ |
| OLD | NEW |