Chromium Code Reviews| Index: src/zone-containers.h |
| diff --git a/src/zone-containers.h b/src/zone-containers.h |
| index 4998cbf3fe990b08208e93da5a49491d96ee5064..3114791fde3ce51d40b967f33ad69014aabb6fff 100644 |
| --- a/src/zone-containers.h |
| +++ b/src/zone-containers.h |
| @@ -7,6 +7,7 @@ |
| #include <deque> |
| #include <queue> |
| +#include <stack> |
| #include <vector> |
| #include "src/zone-allocator.h" |
| @@ -36,29 +37,51 @@ class ZoneVector : public std::vector<T, zone_allocator<T> > { |
| } |
| }; |
| + |
| // A wrapper subclass std::deque to make it easy to construct one |
| // that uses a zone allocator. |
| template <typename T> |
| class ZoneDeque : public std::deque<T, zone_allocator<T> > { |
| public: |
| + // Constructs an empty deque. |
| explicit ZoneDeque(Zone* zone) |
| : std::deque<T, zone_allocator<T> >(zone_allocator<T>(zone)) {} |
| + |
| + // Constructs a new deque and fills it with {size} elements, each constructed |
| + // via the default constructor. |
| + ZoneDeque(int size, Zone* zone) |
|
dcarney
2014/11/13 10:42:15
i really think we should be taking size_t here - i
Benedikt Meurer
2014/11/13 10:50:34
Ups that was dead code anyway.
|
| + : std::deque<T, zone_allocator<T>>(bit_cast<unsigned>(size), T(), |
| + zone_allocator<T>(zone)) {} |
| }; |
| + |
| // A wrapper subclass for std::queue to make it easy to construct one |
| // that uses a zone allocator. |
| template <typename T> |
| -class ZoneQueue : public std::queue<T, std::deque<T, zone_allocator<T> > > { |
| +class ZoneQueue : public std::queue<T, ZoneDeque<T>> { |
| public: |
| // Constructs an empty queue. |
| explicit ZoneQueue(Zone* zone) |
| - : std::queue<T, std::deque<T, zone_allocator<T> > >( |
| - std::deque<T, zone_allocator<T> >(zone_allocator<T>(zone))) {} |
| + : std::queue<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {} |
| +}; |
| + |
| + |
| +// A wrapper subclass for std::stack to make it easy to construct one that uses |
| +// a zone allocator. |
| +template <typename T> |
| +class ZoneStack : public std::stack<T, ZoneDeque<T>> { |
| + public: |
| + // Constructs an empty stack. |
| + explicit ZoneStack(Zone* zone) |
| + : std::stack<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {} |
| }; |
| + |
| // Typedefs to shorten commonly used vectors. |
| typedef ZoneVector<bool> BoolVector; |
| typedef ZoneVector<int> IntVector; |
| -} } // namespace v8::internal |
| + |
| +} // namespace internal |
| +} // namespace v8 |
| #endif // V8_ZONE_CONTAINERS_H_ |