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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 template<typename T, class P> | 123 template<typename T, class P> |
124 void List<T, P>::Iterate(void (*callback)(T* x)) { | 124 void List<T, P>::Iterate(void (*callback)(T* x)) { |
125 for (int i = 0; i < length_; i++) callback(&data_[i]); | 125 for (int i = 0; i < length_; i++) callback(&data_[i]); |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 template<typename T, class P> | 129 template<typename T, class P> |
| 130 template<class Visitor> |
| 131 void List<T, P>::Iterate(Visitor* visitor) { |
| 132 for (int i = 0; i < length_; i++) visitor->Apply(&data_[i]); |
| 133 } |
| 134 |
| 135 |
| 136 template<typename T, class P> |
130 bool List<T, P>::Contains(const T& elm) { | 137 bool List<T, P>::Contains(const T& elm) { |
131 for (int i = 0; i < length_; i++) { | 138 for (int i = 0; i < length_; i++) { |
132 if (data_[i] == elm) | 139 if (data_[i] == elm) |
133 return true; | 140 return true; |
134 } | 141 } |
135 return false; | 142 return false; |
136 } | 143 } |
137 | 144 |
138 | 145 |
139 template<typename T, class P> | 146 template<typename T, class P> |
(...skipping 17 matching lines...) Expand all Loading... |
157 ASSERT(capacity >= 0); | 164 ASSERT(capacity >= 0); |
158 data_ = (capacity > 0) ? NewData(capacity) : NULL; | 165 data_ = (capacity > 0) ? NewData(capacity) : NULL; |
159 capacity_ = capacity; | 166 capacity_ = capacity; |
160 length_ = 0; | 167 length_ = 0; |
161 } | 168 } |
162 | 169 |
163 | 170 |
164 } } // namespace v8::internal | 171 } } // namespace v8::internal |
165 | 172 |
166 #endif // V8_LIST_INL_H_ | 173 #endif // V8_LIST_INL_H_ |
OLD | NEW |