Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Unified Diff: src/zone-containers.h

Issue 505133003: Introduce subclass wrappers for STL containers that make them a lot easier (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/verifier.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone-containers.h
diff --git a/src/zone-containers.h b/src/zone-containers.h
index 1295ed7ab950e40f61c9d7d1928bde1166673a17..f3ac1a8598d5ffea9dc76fb8242ff9c8de694b5b 100644
--- a/src/zone-containers.h
+++ b/src/zone-containers.h
@@ -5,6 +5,8 @@
#ifndef V8_ZONE_CONTAINERS_H_
#define V8_ZONE_CONTAINERS_H_
+#include <deque>
+#include <queue>
#include <vector>
#include "src/zone-allocator.h"
@@ -12,12 +14,44 @@
namespace v8 {
namespace internal {
-typedef std::vector<bool, ZoneBoolAllocator> BoolVector;
-
-typedef std::vector<int, ZoneIntAllocator> IntVector;
-typedef IntVector::iterator IntVectorIter;
-typedef IntVector::reverse_iterator IntVectorRIter;
-
+// A wrapper subclass for std::vector to make it easy to construct one
+// that uses a zone allocator.
+template <typename T>
+class ZoneVector : public std::vector<T, zone_allocator<T>> {
+ public:
+ // Constructs an empty vector.
+ explicit ZoneVector(Zone* zone)
+ : std::vector<T, zone_allocator<T>>(zone_allocator<T>(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<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {}
+};
+
+// 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:
+ explicit ZoneDeque(Zone* zone)
+ : std::deque<T, zone_allocator<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>>> {
+ 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))) {}
+};
+
+// Typedefs to shorten commonly used vectors.
+typedef ZoneVector<bool> BoolVector;
+typedef ZoneVector<int> IntVector;
} } // namespace v8::internal
#endif // V8_ZONE_CONTAINERS_H_
« no previous file with comments | « src/compiler/verifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698