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

Unified Diff: src/zone-containers.h

Issue 889963002: add maps and sets to zone containers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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/register-allocator-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 de635fde05dda6ef0d4058c63552809a86a0469d..0a599bcf2b0501500fc4a17369728a7660cc8107 100644
--- a/src/zone-containers.h
+++ b/src/zone-containers.h
@@ -7,7 +7,9 @@
#include <deque>
#include <list>
+#include <map>
#include <queue>
+#include <set>
#include <stack>
#include <vector>
@@ -83,6 +85,31 @@ class ZoneStack : public std::stack<T, ZoneDeque<T>> {
};
+// A wrapper subclass for std::set to make it easy to construct one that uses
+// a zone allocator.
+template <typename K, typename Compare = std::less<K>>
+class ZoneSet : public std::set<K, Compare, zone_allocator<K>> {
+ public:
+ // Constructs an empty set.
+ explicit ZoneSet(Zone* zone)
+ : std::set<K, Compare, zone_allocator<K>>(Compare(),
+ zone_allocator<K>(zone)) {}
+};
+
+
+// A wrapper subclass for std::map to make it easy to construct one that uses
+// a zone allocator.
+template <typename K, typename V, typename Compare = std::less<K>>
+class ZoneMap
+ : public std::map<K, V, Compare, zone_allocator<std::pair<K, V>>> {
+ public:
+ // Constructs an empty map.
+ explicit ZoneMap(Zone* zone)
+ : std::map<K, V, Compare, zone_allocator<std::pair<K, V>>>(
+ Compare(), zone_allocator<std::pair<K, V>>(zone)) {}
+};
+
+
// Typedefs to shorten commonly used vectors.
typedef ZoneVector<bool> BoolVector;
typedef ZoneVector<int> IntVector;
« no previous file with comments | « src/compiler/register-allocator-verifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698