// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_ZONE_CONTAINERS_H_ #define V8_ZONE_CONTAINERS_H_ #include #include #include #include "src/zone-allocator.h" namespace v8 { namespace internal { // A wrapper subclass for std::vector to make it easy to construct one // that uses a zone allocator. template class ZoneVector : public std::vector > { public: // Constructs an empty vector. explicit ZoneVector(Zone* zone) : std::vector >(zone_allocator(zone)) {} // Constructs a new vector and fills it with {size} elements, each // having the value {def}. ZoneVector(int size, T def, Zone* zone) : std::vector >(size, def, zone_allocator(zone)) { } }; // A wrapper subclass std::deque to make it easy to construct one // that uses a zone allocator. template class ZoneDeque : public std::deque > { public: explicit ZoneDeque(Zone* zone) : std::deque >(zone_allocator(zone)) {} }; // A wrapper subclass for std::queue to make it easy to construct one // that uses a zone allocator. template class ZoneQueue : public std::queue > > { public: // Constructs an empty queue. explicit ZoneQueue(Zone* zone) : std::queue > >( std::deque >(zone_allocator(zone))) {} }; // Typedefs to shorten commonly used vectors. typedef ZoneVector BoolVector; typedef ZoneVector IntVector; } } // namespace v8::internal #endif // V8_ZONE_CONTAINERS_H_