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 <queue> | 10 #include <queue> |
11 #include <stack> | 11 #include <stack> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "src/zone-allocator.h" | 14 #include "src/zone-allocator.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 // A wrapper subclass for std::vector to make it easy to construct one | 19 // A wrapper subclass for std::vector to make it easy to construct one |
20 // that uses a zone allocator. | 20 // that uses a zone allocator. |
21 template <typename T> | 21 template <typename T> |
22 class ZoneVector : public std::vector<T, zone_allocator<T>> { | 22 class ZoneVector : public std::vector<T, zone_allocator<T>> { |
23 public: | 23 public: |
24 // Constructs an empty vector. | 24 // Constructs an empty vector. |
25 explicit ZoneVector(Zone* zone) | 25 explicit ZoneVector(Zone* zone) |
26 : std::vector<T, zone_allocator<T>>(zone_allocator<T>(zone)) {} | 26 : std::vector<T, zone_allocator<T>>(zone_allocator<T>(zone)) {} |
27 | 27 |
28 // Constructs a new vector and fills it with {size} elements, each | 28 // Constructs a new vector and fills it with {size} elements, each |
29 // constructed via the default constructor. | 29 // constructed via the default constructor. |
30 ZoneVector(int size, Zone* zone) | 30 ZoneVector(size_t size, Zone* zone) |
31 : std::vector<T, zone_allocator<T>>(size, T(), zone_allocator<T>(zone)) {} | 31 : std::vector<T, zone_allocator<T>>(size, T(), zone_allocator<T>(zone)) {} |
32 | 32 |
33 // Constructs a new vector and fills it with {size} elements, each | 33 // Constructs a new vector and fills it with {size} elements, each |
34 // having the value {def}. | 34 // having the value {def}. |
35 ZoneVector(int size, T def, Zone* zone) | 35 ZoneVector(size_t size, T def, Zone* zone) |
36 : std::vector<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {} | 36 : std::vector<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {} |
37 }; | 37 }; |
38 | 38 |
39 | 39 |
40 // A wrapper subclass std::deque to make it easy to construct one | 40 // A wrapper subclass std::deque to make it easy to construct one |
41 // that uses a zone allocator. | 41 // that uses a zone allocator. |
42 template <typename T> | 42 template <typename T> |
43 class ZoneDeque : public std::deque<T, zone_allocator<T>> { | 43 class ZoneDeque : public std::deque<T, zone_allocator<T>> { |
44 public: | 44 public: |
45 // Constructs an empty deque. | 45 // Constructs an empty deque. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 | 85 |
86 // Typedefs to shorten commonly used vectors. | 86 // Typedefs to shorten commonly used vectors. |
87 typedef ZoneVector<bool> BoolVector; | 87 typedef ZoneVector<bool> BoolVector; |
88 typedef ZoneVector<int> IntVector; | 88 typedef ZoneVector<int> IntVector; |
89 | 89 |
90 } // namespace internal | 90 } // namespace internal |
91 } // namespace v8 | 91 } // namespace v8 |
92 | 92 |
93 #endif // V8_ZONE_CONTAINERS_H_ | 93 #endif // V8_ZONE_CONTAINERS_H_ |
OLD | NEW |