| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Defines growable array classes, that differ where they are allocated: | 4 // Defines growable array classes, that differ where they are allocated: |
| 5 // - GrowableArray: allocated on stack. | 5 // - GrowableArray: allocated on stack. |
| 6 // - ZoneGrowableArray: allocated in the zone. | 6 // - ZoneGrowableArray: allocated in the zone. |
| 7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called | 7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called |
| 8 // at destruction. | 8 // at destruction. |
| 9 | 9 |
| 10 #ifndef VM_GROWABLE_ARRAY_H_ | 10 #ifndef VM_GROWABLE_ARRAY_H_ |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 208 } |
| 209 | 209 |
| 210 T& operator[](intptr_t index) const { | 210 T& operator[](intptr_t index) const { |
| 211 return *array_[index]; | 211 return *array_[index]; |
| 212 } | 212 } |
| 213 | 213 |
| 214 const T& At(intptr_t index) const { | 214 const T& At(intptr_t index) const { |
| 215 return operator[](index); | 215 return operator[](index); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void SetAt(intptr_t index, const T& t) { |
| 219 array_[index] = &T::ZoneHandle(zone_, t.raw()); |
| 220 } |
| 221 |
| 218 intptr_t length() const { return array_.length(); } | 222 intptr_t length() const { return array_.length(); } |
| 219 | 223 |
| 220 const GrowableArray<T*>& growable_array() const { return array_; } | 224 const GrowableArray<T*>& growable_array() const { return array_; } |
| 221 | 225 |
| 222 private: | 226 private: |
| 223 Zone* zone_; | 227 Zone* zone_; |
| 224 GrowableArray<T*> array_; | 228 GrowableArray<T*> array_; |
| 225 | 229 |
| 226 DISALLOW_COPY_AND_ASSIGN(BaseGrowableHandlePtrArray); | 230 DISALLOW_COPY_AND_ASSIGN(BaseGrowableHandlePtrArray); |
| 227 }; | 231 }; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 public: | 277 public: |
| 274 explicit MallocGrowableArray(intptr_t initial_capacity) | 278 explicit MallocGrowableArray(intptr_t initial_capacity) |
| 275 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {} | 279 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {} |
| 276 MallocGrowableArray() | 280 MallocGrowableArray() |
| 277 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {} | 281 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {} |
| 278 }; | 282 }; |
| 279 | 283 |
| 280 } // namespace dart | 284 } // namespace dart |
| 281 | 285 |
| 282 #endif // VM_GROWABLE_ARRAY_H_ | 286 #endif // VM_GROWABLE_ARRAY_H_ |
| OLD | NEW |