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

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

Issue 331833003: Revert "Add "last" setter to List." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « runtime/lib/array.dart ('k') | runtime/lib/typed_data.dart » ('j') | 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 _GrowableList<T> implements List<T> { 5 class _GrowableList<T> implements List<T> {
6 static final int _classId = (new _GrowableList(0))._cid; 6 static final int _classId = (new _GrowableList(0))._cid;
7 7
8 void insert(int index, T element) { 8 void insert(int index, T element) {
9 if (index < 0 || index > length) { 9 if (index < 0 || index > length) {
10 throw new RangeError.range(index, 0, length); 10 throw new RangeError.range(index, 0, length);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 void _setLength(int new_length) native "GrowableList_setLength"; 151 void _setLength(int new_length) native "GrowableList_setLength";
152 152
153 void _setData(_List array) native "GrowableList_setData"; 153 void _setData(_List array) native "GrowableList_setData";
154 154
155 T operator [](int index) native "GrowableList_getIndexed"; 155 T operator [](int index) native "GrowableList_getIndexed";
156 156
157 void operator []=(int index, T value) native "GrowableList_setIndexed"; 157 void operator []=(int index, T value) native "GrowableList_setIndexed";
158 158
159 void set last(T value) {
160 if (length == 0) throw IterableElementError.noElement();
161 this[length - 1] = value;
162 }
163
164 // The length of this growable array. It is always less than or equal to the 159 // The length of this growable array. It is always less than or equal to the
165 // length of the object array, which itself is always greater than 0, so that 160 // length of the object array, which itself is always greater than 0, so that
166 // grow() does not have to check for a zero length object array before 161 // grow() does not have to check for a zero length object array before
167 // doubling its size. 162 // doubling its size.
168 void add(T value) { 163 void add(T value) {
169 var len = length; 164 var len = length;
170 if (len == _capacity) { 165 if (len == _capacity) {
171 _grow(len * 2); 166 _grow(len * 2);
172 } 167 }
173 _setLength(len + 1); 168 _setLength(len + 1);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 338 }
344 339
345 Set<T> toSet() { 340 Set<T> toSet() {
346 return new Set<T>.from(this); 341 return new Set<T>.from(this);
347 } 342 }
348 343
349 Map<int, T> asMap() { 344 Map<int, T> asMap() {
350 return IterableMixinWorkaround.asMapList(this); 345 return IterableMixinWorkaround.asMapList(this);
351 } 346 }
352 } 347 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/typed_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698