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; |