| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // pointer type. Returns the removed element. | 88 // pointer type. Returns the removed element. |
| 89 INLINE(T RemoveLast()) { return Remove(length_ - 1); } | 89 INLINE(T RemoveLast()) { return Remove(length_ - 1); } |
| 90 | 90 |
| 91 // Clears the list by setting the length to zero. Even if T is a | 91 // Clears the list by setting the length to zero. Even if T is a |
| 92 // pointer type, clearing the list doesn't delete the entries. | 92 // pointer type, clearing the list doesn't delete the entries. |
| 93 INLINE(void Clear()); | 93 INLINE(void Clear()); |
| 94 | 94 |
| 95 // Drops all but the first 'pos' elements from the list. | 95 // Drops all but the first 'pos' elements from the list. |
| 96 INLINE(void Rewind(int pos)); | 96 INLINE(void Rewind(int pos)); |
| 97 | 97 |
| 98 bool Contains(T& elm); |
| 99 |
| 98 // Iterate through all list entries, starting at index 0. | 100 // Iterate through all list entries, starting at index 0. |
| 99 void Iterate(void (*callback)(T* x)); | 101 void Iterate(void (*callback)(T* x)); |
| 100 | 102 |
| 101 // Sort all list entries (using QuickSort) | 103 // Sort all list entries (using QuickSort) |
| 102 void Sort(int (*cmp)(const T* x, const T* y)); | 104 void Sort(int (*cmp)(const T* x, const T* y)); |
| 103 | 105 |
| 104 INLINE(void Initialize(int capacity)); | 106 INLINE(void Initialize(int capacity)); |
| 105 | 107 |
| 106 private: | 108 private: |
| 107 T* data_; | 109 T* data_; |
| 108 int capacity_; | 110 int capacity_; |
| 109 int length_; | 111 int length_; |
| 110 | 112 |
| 111 INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); } | 113 INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); } |
| 112 INLINE(void DeleteData(T* data)) { P::Delete(data); } | 114 INLINE(void DeleteData(T* data)) { P::Delete(data); } |
| 113 | 115 |
| 114 DISALLOW_COPY_AND_ASSIGN(List); | 116 DISALLOW_COPY_AND_ASSIGN(List); |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 | 119 |
| 118 } } // namespace v8::internal | 120 } } // namespace v8::internal |
| 119 | 121 |
| 120 #endif // V8_LIST_H_ | 122 #endif // V8_LIST_H_ |
| OLD | NEW |