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 void Sort(int (*cmp)(const T* x, const T* y), size_t start, size_t length); | 152 template <typename CompareFunction> |
153 void Sort(int (*cmp)(const T* x, const T* y)); | 153 void Sort(CompareFunction cmp, size_t start, size_t length); |
| 154 template <typename CompareFunction> |
| 155 void Sort(CompareFunction cmp); |
154 void Sort(); | 156 void Sort(); |
155 void StableSort(int (*cmp)(const T* x, const T* y), size_t start, | 157 template <typename CompareFunction> |
156 size_t length); | 158 void StableSort(CompareFunction cmp, size_t start, size_t length); |
157 void StableSort(int (*cmp)(const T* x, const T* y)); | 159 template <typename CompareFunction> |
| 160 void StableSort(CompareFunction cmp); |
158 void StableSort(); | 161 void StableSort(); |
159 | 162 |
160 INLINE(void Initialize(int capacity, | 163 INLINE(void Initialize(int capacity, |
161 AllocationPolicy allocator = AllocationPolicy())); | 164 AllocationPolicy allocator = AllocationPolicy())); |
162 | 165 |
163 private: | 166 private: |
164 T* data_; | 167 T* data_; |
165 int capacity_; | 168 int capacity_; |
166 int length_; | 169 int length_; |
167 | 170 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 template <typename T, class P> | 216 template <typename T, class P> |
214 int SortedListBSearch(const List<T>& list, P cmp); | 217 int SortedListBSearch(const List<T>& list, P cmp); |
215 template <typename T> | 218 template <typename T> |
216 int SortedListBSearch(const List<T>& list, T elem); | 219 int SortedListBSearch(const List<T>& list, T elem); |
217 | 220 |
218 | 221 |
219 } } // namespace v8::internal | 222 } } // namespace v8::internal |
220 | 223 |
221 | 224 |
222 #endif // V8_LIST_H_ | 225 #endif // V8_LIST_H_ |
OLD | NEW |