OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 ToVector().Sort(cmp); | 209 ToVector().Sort(cmp); |
210 #ifdef DEBUG | 210 #ifdef DEBUG |
211 for (int i = 1; i < length_; i++) | 211 for (int i = 1; i < length_; i++) |
212 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0); | 212 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0); |
213 #endif | 213 #endif |
214 } | 214 } |
215 | 215 |
216 | 216 |
217 template<typename T, class P> | 217 template<typename T, class P> |
218 void List<T, P>::Sort() { | 218 void List<T, P>::Sort() { |
219 Sort(PointerValueCompare<T>); | 219 ToVector().Sort(); |
220 } | 220 } |
221 | 221 |
222 | 222 |
223 template<typename T, class P> | 223 template<typename T, class P> |
224 void List<T, P>::Initialize(int capacity, P allocator) { | 224 void List<T, P>::Initialize(int capacity, P allocator) { |
225 ASSERT(capacity >= 0); | 225 ASSERT(capacity >= 0); |
226 data_ = (capacity > 0) ? NewData(capacity, allocator) : NULL; | 226 data_ = (capacity > 0) ? NewData(capacity, allocator) : NULL; |
227 capacity_ = capacity; | 227 capacity_ = capacity; |
228 length_ = 0; | 228 length_ = 0; |
229 } | 229 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 template <typename T> | 267 template <typename T> |
268 int SortedListBSearch(const List<T>& list, T elem) { | 268 int SortedListBSearch(const List<T>& list, T elem) { |
269 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); | 269 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); |
270 } | 270 } |
271 | 271 |
272 | 272 |
273 } } // namespace v8::internal | 273 } } // namespace v8::internal |
274 | 274 |
275 #endif // V8_LIST_INL_H_ | 275 #endif // V8_LIST_INL_H_ |
OLD | NEW |