| Index: src/list-inl.h
|
| ===================================================================
|
| --- src/list-inl.h (revision 830)
|
| +++ src/list-inl.h (working copy)
|
| @@ -90,11 +90,18 @@
|
|
|
|
|
| template<typename T, class P>
|
| +bool List<T, P>::Contains(const T& elm) {
|
| + for (int i = 0; i < length_; i++) {
|
| + if (data_[i] == elm)
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +
|
| +template<typename T, class P>
|
| void List<T, P>::Sort(int (*cmp)(const T* x, const T* y)) {
|
| - qsort(data_,
|
| - length_,
|
| - sizeof(T),
|
| - reinterpret_cast<int (*)(const void*, const void*)>(cmp));
|
| + ToVector().Sort(cmp);
|
| #ifdef DEBUG
|
| for (int i = 1; i < length_; i++)
|
| ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0);
|
| @@ -103,6 +110,12 @@
|
|
|
|
|
| template<typename T, class P>
|
| +void List<T, P>::Sort() {
|
| + Sort(PointerSpaceship<T>);
|
| +}
|
| +
|
| +
|
| +template<typename T, class P>
|
| void List<T, P>::Initialize(int capacity) {
|
| ASSERT(capacity >= 0);
|
| data_ = (capacity > 0) ? NewData(capacity) : NULL;
|
|
|