OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.collection.dev; | 5 part of dart.collection.dev; |
6 | 6 |
7 /** | 7 /** |
8 * Class implementing the read-operations on [List]. | 8 * Class implementing the read-operations on [List]. |
9 * | 9 * |
10 * Implements all read-only operations, except [:operator[]:] and [:length:], | 10 * Implements all read-only operations, except [:operator[]:] and [:length:], |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 List<E> take(int n) { | 100 List<E> take(int n) { |
101 return new ListView(this, 0, n); | 101 return new ListView(this, 0, n); |
102 } | 102 } |
103 | 103 |
104 List<E> skip(int n) { | 104 List<E> skip(int n) { |
105 return new ListView(this, n, null); | 105 return new ListView(this, n, null); |
106 } | 106 } |
107 | 107 |
108 String toString() => ToString.collectionToString(this); | 108 String toString() => ToString.collectionToString(this); |
| 109 |
| 110 List<E> get reversed { |
| 111 return new ReversedListView(this, 0, null); |
| 112 } |
109 } | 113 } |
110 | 114 |
111 /** | 115 /** |
112 * Abstract class implementing the non-length changing operations of [List]. | 116 * Abstract class implementing the non-length changing operations of [List]. |
113 */ | 117 */ |
114 abstract class FixedLengthListBase<E> extends ListBase<E> { | 118 abstract class FixedLengthListBase<E> extends ListBase<E> { |
115 void operator[]=(int index, E value); | 119 void operator[]=(int index, E value); |
116 | 120 |
117 List<E> get reversed => new ReversedListView<E>(this, 0, null); | |
118 | |
119 void sort([Comparator<E> compare]) { | 121 void sort([Comparator<E> compare]) { |
120 Sort.sort(this, compare); | 122 Sort.sort(this, compare); |
121 } | 123 } |
122 | 124 |
123 void setRange(int start, int length, List<E> from, [int startFrom]) { | 125 void setRange(int start, int length, List<E> from, [int startFrom]) { |
124 if (length < 0) throw new ArgumentError("length: $length"); | 126 if (length < 0) throw new ArgumentError("length: $length"); |
125 if (startFrom == null) startFrom = 0; | 127 if (startFrom == null) startFrom = 0; |
126 for (int i = 0; i < length; i++) { | 128 for (int i = 0; i < length; i++) { |
127 this[start + i] = from[startFrom + i]; | 129 this[start + i] = from[startFrom + i]; |
128 } | 130 } |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 E _current; | 526 E _current; |
525 | 527 |
526 ReverseListIterator(List<E> list, int start, int end) | 528 ReverseListIterator(List<E> list, int start, int end) |
527 : _list = list, | 529 : _list = list, |
528 _start = start, | 530 _start = start, |
529 _index = end, | 531 _index = end, |
530 _originalLength = list.length; | 532 _originalLength = list.length; |
531 | 533 |
532 bool moveNext() { | 534 bool moveNext() { |
533 if (_list.length != _originalLength) { | 535 if (_list.length != _originalLength) { |
534 throw new ConcurrentModificationError(list); | 536 throw new ConcurrentModificationError(_list); |
535 } | 537 } |
536 if (_index <= _start) return false; | 538 if (_index <= _start) return false; |
537 _index -= 1; | 539 _index -= 1; |
538 _current = _list[_index]; | 540 _current = _list[_index]; |
539 return true; | 541 return true; |
540 } | 542 } |
541 | 543 |
542 E get current => _current; | 544 E get current => _current; |
543 } | 545 } |
OLD | NEW |