| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } | 85 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } |
| 86 | 86 |
| 87 // Adds a copy of the given 'element' to the end of the list, | 87 // Adds a copy of the given 'element' to the end of the list, |
| 88 // expanding the list if necessary. | 88 // expanding the list if necessary. |
| 89 void Add(const T& element); | 89 void Add(const T& element); |
| 90 | 90 |
| 91 // Add all the elements from the argument list to this list. | 91 // Add all the elements from the argument list to this list. |
| 92 void AddAll(const List<T, P>& other); | 92 void AddAll(const List<T, P>& other); |
| 93 | 93 |
| 94 // Inserts the element at the specific index. |
| 95 void InsertAt(int index, const T& element); |
| 96 |
| 94 // Added 'count' elements with the value 'value' and returns a | 97 // Added 'count' elements with the value 'value' and returns a |
| 95 // vector that allows access to the elements. The vector is valid | 98 // vector that allows access to the elements. The vector is valid |
| 96 // until the next change is made to this list. | 99 // until the next change is made to this list. |
| 97 Vector<T> AddBlock(T value, int count); | 100 Vector<T> AddBlock(T value, int count); |
| 98 | 101 |
| 99 // Removes the i'th element without deleting it even if T is a | 102 // Removes the i'th element without deleting it even if T is a |
| 100 // pointer type; moves all elements above i "down". Returns the | 103 // pointer type; moves all elements above i "down". Returns the |
| 101 // removed element. This function's complexity is linear in the | 104 // removed element. This function's complexity is linear in the |
| 102 // size of the list. | 105 // size of the list. |
| 103 T Remove(int i); | 106 T Remove(int i); |
| 104 | 107 |
| 108 // Remove the given element from the list. Returns whether or not |
| 109 // the input is included in the list in the first place. |
| 110 bool RemoveElement(const T& elm); |
| 111 |
| 105 // Removes the last element without deleting it even if T is a | 112 // Removes the last element without deleting it even if T is a |
| 106 // pointer type. Returns the removed element. | 113 // pointer type. Returns the removed element. |
| 107 INLINE(T RemoveLast()) { return Remove(length_ - 1); } | 114 INLINE(T RemoveLast()) { return Remove(length_ - 1); } |
| 108 | 115 |
| 109 // Clears the list by setting the length to zero. Even if T is a | 116 // Clears the list by setting the length to zero. Even if T is a |
| 110 // pointer type, clearing the list doesn't delete the entries. | 117 // pointer type, clearing the list doesn't delete the entries. |
| 111 INLINE(void Clear()); | 118 INLINE(void Clear()); |
| 112 | 119 |
| 113 // Drops all but the first 'pos' elements from the list. | 120 // Drops all but the first 'pos' elements from the list. |
| 114 INLINE(void Rewind(int pos)); | 121 INLINE(void Rewind(int pos)); |
| 115 | 122 |
| 116 bool Contains(const T& elm); | 123 // Drop the last 'count' elements from the list. |
| 124 INLINE(void RewindBy(int count)) { Rewind(length_ - count); } |
| 125 |
| 126 bool Contains(const T& elm) const; |
| 127 int CountOccurrences(const T& elm, int start, int end) const; |
| 117 | 128 |
| 118 // Iterate through all list entries, starting at index 0. | 129 // Iterate through all list entries, starting at index 0. |
| 119 void Iterate(void (*callback)(T* x)); | 130 void Iterate(void (*callback)(T* x)); |
| 120 template<class Visitor> | 131 template<class Visitor> |
| 121 void Iterate(Visitor* visitor); | 132 void Iterate(Visitor* visitor); |
| 122 | 133 |
| 123 // Sort all list entries (using QuickSort) | 134 // Sort all list entries (using QuickSort) |
| 124 void Sort(int (*cmp)(const T* x, const T* y)); | 135 void Sort(int (*cmp)(const T* x, const T* y)); |
| 125 void Sort(); | 136 void Sort(); |
| 126 | 137 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 144 | 155 |
| 145 // Resize the list. | 156 // Resize the list. |
| 146 void Resize(int new_capacity); | 157 void Resize(int new_capacity); |
| 147 | 158 |
| 148 DISALLOW_COPY_AND_ASSIGN(List); | 159 DISALLOW_COPY_AND_ASSIGN(List); |
| 149 }; | 160 }; |
| 150 | 161 |
| 151 } } // namespace v8::internal | 162 } } // namespace v8::internal |
| 152 | 163 |
| 153 #endif // V8_LIST_H_ | 164 #endif // V8_LIST_H_ |
| OLD | NEW |