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

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

Issue 12262037: Make List.skip, List.take and List.reversed return Iterables, not Lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments, small fixes. Created 7 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
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 5
6 // TODO(srdjan): Use shared array implementation. 6 // TODO(srdjan): Use shared array implementation.
7 class _ObjectArray<E> implements List<E> { 7 class _ObjectArray<E> implements List<E> {
8 8
9 factory _ObjectArray(int length) native "ObjectArray_allocate"; 9 factory _ObjectArray(int length) native "ObjectArray_allocate";
10 10
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 E elementAt(int index) { 159 E elementAt(int index) {
160 return this[index]; 160 return this[index];
161 } 161 }
162 162
163 bool get isEmpty { 163 bool get isEmpty {
164 return this.length == 0; 164 return this.length == 0;
165 } 165 }
166 166
167 List<E> get reversed => new ReversedListView<E>(this, 0, null); 167 Iterable<E> get reversed => new ReversedListIterable<E>(this);
168 168
169 void sort([int compare(E a, E b)]) { 169 void sort([int compare(E a, E b)]) {
170 IterableMixinWorkaround.sortList(this, compare); 170 IterableMixinWorkaround.sortList(this, compare);
171 } 171 }
172 172
173 int indexOf(E element, [int start = 0]) { 173 int indexOf(E element, [int start = 0]) {
174 return Arrays.indexOf(this, element, start, this.length); 174 return Arrays.indexOf(this, element, start, this.length);
175 } 175 }
176 176
177 int lastIndexOf(E element, [int start = null]) { 177 int lastIndexOf(E element, [int start = null]) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 395 }
396 396
397 E elementAt(int index) { 397 E elementAt(int index) {
398 return this[index]; 398 return this[index];
399 } 399 }
400 400
401 bool get isEmpty { 401 bool get isEmpty {
402 return this.length == 0; 402 return this.length == 0;
403 } 403 }
404 404
405 List<E> get reversed => new ReversedListView<E>(this, 0, null); 405 Iterable<E> get reversed => new ReversedListIterable<E>(this);
406 406
407 void sort([int compare(E a, E b)]) { 407 void sort([int compare(E a, E b)]) {
408 throw new UnsupportedError( 408 throw new UnsupportedError(
409 "Cannot modify an immutable array"); 409 "Cannot modify an immutable array");
410 } 410 }
411 411
412 String toString() { 412 String toString() {
413 return Collections.collectionToString(this); 413 return Collections.collectionToString(this);
414 } 414 }
415 415
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 } 506 }
507 _position = _length; 507 _position = _length;
508 _current = null; 508 _current = null;
509 return false; 509 return false;
510 } 510 }
511 511
512 E get current { 512 E get current {
513 return _current; 513 return _current;
514 } 514 }
515 } 515 }
OLDNEW
« no previous file with comments | « pkg/analyzer-experimental/lib/src/generated/java_core.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698