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 | 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 E elementAt(int index) { | 149 E elementAt(int index) { |
150 return this[index]; | 150 return this[index]; |
151 } | 151 } |
152 | 152 |
153 bool get isEmpty { | 153 bool get isEmpty { |
154 return this.length == 0; | 154 return this.length == 0; |
155 } | 155 } |
156 | 156 |
| 157 List<E> get reversed => new ReversedList<E>(this, 0, length); |
| 158 |
157 void sort([int compare(E a, E b)]) { | 159 void sort([int compare(E a, E b)]) { |
158 if (compare == null) compare = Comparable.compare; | 160 if (compare == null) compare = Comparable.compare; |
159 _Sort.sort(this, compare); | 161 _Sort.sort(this, compare); |
160 } | 162 } |
161 | 163 |
162 int indexOf(E element, [int start = 0]) { | 164 int indexOf(E element, [int start = 0]) { |
163 return Arrays.indexOf(this, element, start, this.length); | 165 return Arrays.indexOf(this, element, start, this.length); |
164 } | 166 } |
165 | 167 |
166 int lastIndexOf(E element, [int start = null]) { | 168 int lastIndexOf(E element, [int start = null]) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 378 } |
377 | 379 |
378 E elementAt(int index) { | 380 E elementAt(int index) { |
379 return this[index]; | 381 return this[index]; |
380 } | 382 } |
381 | 383 |
382 bool get isEmpty { | 384 bool get isEmpty { |
383 return this.length == 0; | 385 return this.length == 0; |
384 } | 386 } |
385 | 387 |
| 388 List<E> get reversed => new ReversedList<E>(this, 0, length); |
| 389 |
386 void sort([int compare(E a, E b)]) { | 390 void sort([int compare(E a, E b)]) { |
387 throw new UnsupportedError( | 391 throw new UnsupportedError( |
388 "Cannot modify an immutable array"); | 392 "Cannot modify an immutable array"); |
389 } | 393 } |
390 | 394 |
391 String toString() { | 395 String toString() { |
392 return Collections.collectionToString(this); | 396 return Collections.collectionToString(this); |
393 } | 397 } |
394 | 398 |
395 int indexOf(E element, [int start = 0]) { | 399 int indexOf(E element, [int start = 0]) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 489 } |
486 _position = _length; | 490 _position = _length; |
487 _current = null; | 491 _current = null; |
488 return false; | 492 return false; |
489 } | 493 } |
490 | 494 |
491 E get current { | 495 E get current { |
492 return _current; | 496 return _current; |
493 } | 497 } |
494 } | 498 } |
OLD | NEW |