Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Side by Side Diff: runtime/lib/growable_array.dart

Issue 9431024: List.add is void (returns null). Fix issue 1213. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 class GrowableObjectArray<T> implements List<T> { 5 class GrowableObjectArray<T> implements List<T> {
6 ObjectArray<T> backingArray; 6 ObjectArray<T> backingArray;
7 7
8 factory GrowableObjectArray._uninstantiable() { 8 factory GrowableObjectArray._uninstantiable() {
9 throw const UnsupportedOperationException( 9 throw const UnsupportedOperationException(
10 "GrowableObjectArray can only be allocated by the VM"); 10 "GrowableObjectArray can only be allocated by the VM");
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 void grow(int capacity) { 138 void grow(int capacity) {
139 ObjectArray<T> newArray = new ObjectArray<T>(capacity); 139 ObjectArray<T> newArray = new ObjectArray<T>(capacity);
140 int length = backingArray.length; 140 int length = backingArray.length;
141 for (int i = 0; i < length; i++) { 141 for (int i = 0; i < length; i++) {
142 newArray[i] = backingArray[i]; 142 newArray[i] = backingArray[i];
143 } 143 }
144 backingArray = newArray; 144 backingArray = newArray;
145 } 145 }
146 146
147 int add(T value) { 147 void add(T value) {
148 if (_length == backingArray.length) { 148 if (_length == backingArray.length) {
149 grow(_length * 2); 149 grow(_length * 2);
150 } 150 }
151 backingArray[_length] = value; 151 backingArray[_length] = value;
152 return ++_length; 152 ++_length;
153 } 153 }
154 154
155 void addLast(T element) { 155 void addLast(T element) {
156 add(element); 156 add(element);
157 } 157 }
158 158
159 void addAll(Collection<T> collection) { 159 void addAll(Collection<T> collection) {
160 for (T elem in collection) { 160 for (T elem in collection) {
161 add(elem); 161 add(elem);
162 } 162 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (!hasNext()) { 250 if (!hasNext()) {
251 throw const NoMoreElementsException(); 251 throw const NoMoreElementsException();
252 } 252 }
253 return _array[_pos++]; 253 return _array[_pos++];
254 } 254 }
255 255
256 final GrowableObjectArray<T> _array; 256 final GrowableObjectArray<T> _array;
257 int _pos; 257 int _pos;
258 } 258 }
259 259
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698