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

Side by Side 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, 10 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 unified diff | Download patch
« no previous file with comments | « src/compiler/register-allocator-verifier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_ZONE_CONTAINERS_H_ 5 #ifndef V8_ZONE_CONTAINERS_H_
6 #define V8_ZONE_CONTAINERS_H_ 6 #define V8_ZONE_CONTAINERS_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map>
10 #include <queue> 11 #include <queue>
12 #include <set>
11 #include <stack> 13 #include <stack>
12 #include <vector> 14 #include <vector>
13 15
14 #include "src/zone-allocator.h" 16 #include "src/zone-allocator.h"
15 17
16 namespace v8 { 18 namespace v8 {
17 namespace internal { 19 namespace internal {
18 20
19 // A wrapper subclass for std::vector to make it easy to construct one 21 // A wrapper subclass for std::vector to make it easy to construct one
20 // that uses a zone allocator. 22 // that uses a zone allocator.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // a zone allocator. 78 // a zone allocator.
77 template <typename T> 79 template <typename T>
78 class ZoneStack : public std::stack<T, ZoneDeque<T>> { 80 class ZoneStack : public std::stack<T, ZoneDeque<T>> {
79 public: 81 public:
80 // Constructs an empty stack. 82 // Constructs an empty stack.
81 explicit ZoneStack(Zone* zone) 83 explicit ZoneStack(Zone* zone)
82 : std::stack<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {} 84 : std::stack<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {}
83 }; 85 };
84 86
85 87
88 // A wrapper subclass for std::set to make it easy to construct one that uses
89 // a zone allocator.
90 template <typename K, typename Compare = std::less<K>>
91 class ZoneSet : public std::set<K, Compare, zone_allocator<K>> {
92 public:
93 // Constructs an empty set.
94 explicit ZoneSet(Zone* zone)
95 : std::set<K, Compare, zone_allocator<K>>(Compare(),
96 zone_allocator<K>(zone)) {}
97 };
98
99
100 // A wrapper subclass for std::map to make it easy to construct one that uses
101 // a zone allocator.
102 template <typename K, typename V, typename Compare = std::less<K>>
103 class ZoneMap
104 : public std::map<K, V, Compare, zone_allocator<std::pair<K, V>>> {
105 public:
106 // Constructs an empty map.
107 explicit ZoneMap(Zone* zone)
108 : std::map<K, V, Compare, zone_allocator<std::pair<K, V>>>(
109 Compare(), zone_allocator<std::pair<K, V>>(zone)) {}
110 };
111
112
86 // Typedefs to shorten commonly used vectors. 113 // Typedefs to shorten commonly used vectors.
87 typedef ZoneVector<bool> BoolVector; 114 typedef ZoneVector<bool> BoolVector;
88 typedef ZoneVector<int> IntVector; 115 typedef ZoneVector<int> IntVector;
89 116
90 } // namespace internal 117 } // namespace internal
91 } // namespace v8 118 } // namespace v8
92 119
93 #endif // V8_ZONE_CONTAINERS_H_ 120 #endif // V8_ZONE_CONTAINERS_H_
OLDNEW
« 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