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

Side by Side Diff: sdk/lib/html/templates/immutable_list_mixin.darttemplate

Issue 11727007: Add min and max to Iterable and Stream. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Created 7 years, 11 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 // -- start List<$E> mixins. 1 // -- start List<$E> mixins.
2 // $E is the element type. 2 // $E is the element type.
3 3
4 // From Iterable<$E>: 4 // From Iterable<$E>:
5 5
6 Iterator<$E> get iterator { 6 Iterator<$E> get iterator {
7 // Note: NodeLists are not fixed size. And most probably length shouldn't 7 // Note: NodeLists are not fixed size. And most probably length shouldn't
8 // be cached in both iterator _and_ forEach method. For now caching it 8 // be cached in both iterator _and_ forEach method. For now caching it
9 // for consistency. 9 // for consistency.
10 return new FixedSizeListIterator<$E>(this); 10 return new FixedSizeListIterator<$E>(this);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (this.length > 0) return this[this.length - 1]; 116 if (this.length > 0) return this[this.length - 1];
117 throw new StateError("No elements"); 117 throw new StateError("No elements");
118 } 118 }
119 119
120 $E get single { 120 $E get single {
121 if (length == 1) return this[0]; 121 if (length == 1) return this[0];
122 if (length == 0) throw new StateError("No elements"); 122 if (length == 0) throw new StateError("No elements");
123 throw new StateError("More than one element"); 123 throw new StateError("More than one element");
124 } 124 }
125 125
126 $E min([int compare($E a, $E b)]) => _Collections.minInList(this, compare);
127
128 $E max([int compare($E a, $E b)]) => _Collections.maxInList(this, compare);
129
126 $E removeAt(int pos) { 130 $E removeAt(int pos) {
127 throw new UnsupportedError("Cannot removeAt on immutable List."); 131 throw new UnsupportedError("Cannot removeAt on immutable List.");
128 } 132 }
129 133
130 $E removeLast() { 134 $E removeLast() {
131 throw new UnsupportedError("Cannot removeLast on immutable List."); 135 throw new UnsupportedError("Cannot removeLast on immutable List.");
132 } 136 }
133 137
134 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { 138 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) {
135 throw new UnsupportedError("Cannot setRange on immutable List."); 139 throw new UnsupportedError("Cannot setRange on immutable List.");
136 } 140 }
137 141
138 void removeRange(int start, int rangeLength) { 142 void removeRange(int start, int rangeLength) {
139 throw new UnsupportedError("Cannot removeRange on immutable List."); 143 throw new UnsupportedError("Cannot removeRange on immutable List.");
140 } 144 }
141 145
142 void insertRange(int start, int rangeLength, [$E initialValue]) { 146 void insertRange(int start, int rangeLength, [$E initialValue]) {
143 throw new UnsupportedError("Cannot insertRange on immutable List."); 147 throw new UnsupportedError("Cannot insertRange on immutable List.");
144 } 148 }
145 149
146 List<$E> getRange(int start, int rangeLength) => 150 List<$E> getRange(int start, int rangeLength) =>
147 Lists.getRange(this, start, rangeLength, <$E>[]); 151 Lists.getRange(this, start, rangeLength, <$E>[]);
148 152
149 // -- end List<$E> mixins. 153 // -- end List<$E> mixins.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698