OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_LIST_H_ | 5 #ifndef V8_LIST_H_ |
6 #define V8_LIST_H_ | 6 #define V8_LIST_H_ |
7 | 7 |
| 8 #include <algorithm> |
| 9 |
8 #include "src/checks.h" | 10 #include "src/checks.h" |
9 #include "src/utils.h" | 11 #include "src/utils.h" |
10 | 12 |
11 namespace v8 { | 13 namespace v8 { |
12 namespace internal { | 14 namespace internal { |
13 | 15 |
14 template<typename T> class Vector; | 16 template<typename T> class Vector; |
15 | 17 |
16 // ---------------------------------------------------------------------------- | 18 // ---------------------------------------------------------------------------- |
17 // The list is a template for very light-weight lists. We are not | 19 // The list is a template for very light-weight lists. We are not |
(...skipping 112 matching lines...) Loading... |
130 // Clears the list by setting the length to zero. Even if T is a | 132 // Clears the list by setting the length to zero. Even if T is a |
131 // pointer type, clearing the list doesn't delete the entries. | 133 // pointer type, clearing the list doesn't delete the entries. |
132 INLINE(void Clear()); | 134 INLINE(void Clear()); |
133 | 135 |
134 // Drops all but the first 'pos' elements from the list. | 136 // Drops all but the first 'pos' elements from the list. |
135 INLINE(void Rewind(int pos)); | 137 INLINE(void Rewind(int pos)); |
136 | 138 |
137 // Drop the last 'count' elements from the list. | 139 // Drop the last 'count' elements from the list. |
138 INLINE(void RewindBy(int count)) { Rewind(length_ - count); } | 140 INLINE(void RewindBy(int count)) { Rewind(length_ - count); } |
139 | 141 |
| 142 // Swaps the contents of the two lists. |
| 143 INLINE(void Swap(List<T, AllocationPolicy>* list)); |
| 144 |
140 // Halve the capacity if fill level is less than a quarter. | 145 // Halve the capacity if fill level is less than a quarter. |
141 INLINE(void Trim(AllocationPolicy allocator = AllocationPolicy())); | 146 INLINE(void Trim(AllocationPolicy allocator = AllocationPolicy())); |
142 | 147 |
143 bool Contains(const T& elm) const; | 148 bool Contains(const T& elm) const; |
144 int CountOccurrences(const T& elm, int start, int end) const; | 149 int CountOccurrences(const T& elm, int start, int end) const; |
145 | 150 |
146 // Iterate through all list entries, starting at index 0. | 151 // Iterate through all list entries, starting at index 0. |
147 void Iterate(void (*callback)(T* x)); | 152 void Iterate(void (*callback)(T* x)); |
148 template<class Visitor> | 153 template<class Visitor> |
149 void Iterate(Visitor* visitor); | 154 void Iterate(Visitor* visitor); |
(...skipping 66 matching lines...) Loading... |
216 template <typename T, class P> | 221 template <typename T, class P> |
217 int SortedListBSearch(const List<T>& list, P cmp); | 222 int SortedListBSearch(const List<T>& list, P cmp); |
218 template <typename T> | 223 template <typename T> |
219 int SortedListBSearch(const List<T>& list, T elem); | 224 int SortedListBSearch(const List<T>& list, T elem); |
220 | 225 |
221 | 226 |
222 } } // namespace v8::internal | 227 } } // namespace v8::internal |
223 | 228 |
224 | 229 |
225 #endif // V8_LIST_H_ | 230 #endif // V8_LIST_H_ |
OLD | NEW |