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 "src/checks.h" | 8 #include "src/checks.h" |
9 #include "src/utils.h" | 9 #include "src/utils.h" |
10 | 10 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 bool Contains(const T& elm) const; | 143 bool Contains(const T& elm) const; |
144 int CountOccurrences(const T& elm, int start, int end) const; | 144 int CountOccurrences(const T& elm, int start, int end) const; |
145 | 145 |
146 // Iterate through all list entries, starting at index 0. | 146 // Iterate through all list entries, starting at index 0. |
147 void Iterate(void (*callback)(T* x)); | 147 void Iterate(void (*callback)(T* x)); |
148 template<class Visitor> | 148 template<class Visitor> |
149 void Iterate(Visitor* visitor); | 149 void Iterate(Visitor* visitor); |
150 | 150 |
151 // Sort all list entries (using QuickSort) | 151 // Sort all list entries (using QuickSort) |
152 template <typename CompareFunction> | 152 void Sort(int (*cmp)(const T* x, const T* y), size_t start, size_t length); |
153 void Sort(CompareFunction cmp, size_t start, size_t length); | 153 void Sort(int (*cmp)(const T* x, const T* y)); |
154 template <typename CompareFunction> | |
155 void Sort(CompareFunction cmp); | |
156 void Sort(); | 154 void Sort(); |
157 template <typename CompareFunction> | 155 void StableSort(int (*cmp)(const T* x, const T* y), size_t start, |
158 void StableSort(CompareFunction cmp, size_t start, size_t length); | 156 size_t length); |
159 template <typename CompareFunction> | 157 void StableSort(int (*cmp)(const T* x, const T* y)); |
160 void StableSort(CompareFunction cmp); | |
161 void StableSort(); | 158 void StableSort(); |
162 | 159 |
163 INLINE(void Initialize(int capacity, | 160 INLINE(void Initialize(int capacity, |
164 AllocationPolicy allocator = AllocationPolicy())); | 161 AllocationPolicy allocator = AllocationPolicy())); |
165 | 162 |
166 private: | 163 private: |
167 T* data_; | 164 T* data_; |
168 int capacity_; | 165 int capacity_; |
169 int length_; | 166 int length_; |
170 | 167 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 template <typename T, class P> | 213 template <typename T, class P> |
217 int SortedListBSearch(const List<T>& list, P cmp); | 214 int SortedListBSearch(const List<T>& list, P cmp); |
218 template <typename T> | 215 template <typename T> |
219 int SortedListBSearch(const List<T>& list, T elem); | 216 int SortedListBSearch(const List<T>& list, T elem); |
220 | 217 |
221 | 218 |
222 } } // namespace v8::internal | 219 } } // namespace v8::internal |
223 | 220 |
224 | 221 |
225 #endif // V8_LIST_H_ | 222 #endif // V8_LIST_H_ |
OLD | NEW |