| 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 | 7 |
| 8 #ifndef VM_GROWABLE_ARRAY_H_ | 8 #ifndef VM_GROWABLE_ARRAY_H_ |
| 9 #define VM_GROWABLE_ARRAY_H_ | 9 #define VM_GROWABLE_ARRAY_H_ |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 return result; | 53 return result; |
| 54 } | 54 } |
| 55 | 55 |
| 56 T& operator[](intptr_t index) const { | 56 T& operator[](intptr_t index) const { |
| 57 ASSERT(0 <= index); | 57 ASSERT(0 <= index); |
| 58 ASSERT(index < length_); | 58 ASSERT(index < length_); |
| 59 ASSERT(length_ <= capacity_); | 59 ASSERT(length_ <= capacity_); |
| 60 return data_[index]; | 60 return data_[index]; |
| 61 } | 61 } |
| 62 | 62 |
| 63 const T& At(intptr_t index) const { |
| 64 return operator[](index); |
| 65 } |
| 66 |
| 63 T& Last() const { | 67 T& Last() const { |
| 64 ASSERT(length_ > 0); | 68 ASSERT(length_ > 0); |
| 65 return operator[](length_ - 1); | 69 return operator[](length_ - 1); |
| 66 } | 70 } |
| 67 | 71 |
| 68 void AddArray(const BaseGrowableArray<T, B>& src) { | 72 void AddArray(const BaseGrowableArray<T, B>& src) { |
| 69 for (intptr_t i = 0; i < src.length(); i++) { | 73 for (intptr_t i = 0; i < src.length(); i++) { |
| 70 Add(src[i]); | 74 Add(src[i]); |
| 71 } | 75 } |
| 72 } | 76 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 initial_capacity, | 165 initial_capacity, |
| 162 Isolate::Current()->current_zone()) {} | 166 Isolate::Current()->current_zone()) {} |
| 163 ZoneGrowableArray() : | 167 ZoneGrowableArray() : |
| 164 BaseGrowableArray<T, ZoneAllocated>( | 168 BaseGrowableArray<T, ZoneAllocated>( |
| 165 Isolate::Current()->current_zone()) {} | 169 Isolate::Current()->current_zone()) {} |
| 166 }; | 170 }; |
| 167 | 171 |
| 168 } // namespace dart | 172 } // namespace dart |
| 169 | 173 |
| 170 #endif // VM_GROWABLE_ARRAY_H_ | 174 #endif // VM_GROWABLE_ARRAY_H_ |
| OLD | NEW |