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

Side by Side Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 14071002: Added new version of reduce. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed more uses of max, and a few bugs. Created 7 years, 8 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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
8 // functionality. 8 // functionality.
9 class _ChildrenElementList extends ListBase<Element> { 9 class _ChildrenElementList extends ListBase<Element> {
10 // Raw Element. 10 // Raw Element.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 Iterable<Element> get reversed { 152 Iterable<Element> get reversed {
153 return _childElements.reversed; 153 return _childElements.reversed;
154 } 154 }
155 155
156 void sort([int compare(Element a, Element b)]) { 156 void sort([int compare(Element a, Element b)]) {
157 throw new UnsupportedError('TODO(jacobr): should we impl?'); 157 throw new UnsupportedError('TODO(jacobr): should we impl?');
158 } 158 }
159 159
160 dynamic reduce(dynamic initialValue, 160 Element reduce(Element combine(Element value, Element element)) {
161 dynamic combine(dynamic previousValue, Element element)) { 161 return _childElements.reduce(combine);
162 return _childElements.reduce(initialValue, combine);
163 } 162 }
164 163
165 dynamic fold(dynamic initialValue, 164 dynamic fold(dynamic initialValue,
166 dynamic combine(dynamic previousValue, Element element)) { 165 dynamic combine(dynamic previousValue, Element element)) {
167 return _childElements.fold(initialValue, combine); 166 return _childElements.fold(initialValue, combine);
168 } 167 }
169 168
170 void setRange(int start, int rangeLength, List from, 169 void setRange(int start, int rangeLength, List from,
171 [int startFrom = 0]) { 170 [int startFrom = 0]) {
172 throw new UnimplementedError(); 171 throw new UnimplementedError();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 Element result = _element.$dom_lastElementChild; 264 Element result = _element.$dom_lastElementChild;
266 if (result == null) throw new StateError("No elements"); 265 if (result == null) throw new StateError("No elements");
267 return result; 266 return result;
268 } 267 }
269 268
270 Element get single { 269 Element get single {
271 if (length > 1) throw new StateError("More than one element"); 270 if (length > 1) throw new StateError("More than one element");
272 return first; 271 return first;
273 } 272 }
274 273
275 Element min([int compare(Element a, Element b)]) {
276 return _childElements.min(compare);
277 }
278
279 Element max([int compare(Element a, Element b)]) {
280 return _childElements.max(compare);
281 }
282
283 Map<int, Element> asMap() { 274 Map<int, Element> asMap() {
284 return _childElements.asMap(); 275 return _childElements.asMap();
285 } 276 }
286 277
287 String toString() { 278 String toString() {
288 StringBuffer buffer = new StringBuffer('['); 279 StringBuffer buffer = new StringBuffer('[');
289 buffer.writeAll(this, ', '); 280 buffer.writeAll(this, ', ');
290 buffer.write(']'); 281 buffer.write(']');
291 return buffer.toString(); 282 return buffer.toString();
292 } 283 }
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 const ScrollAlignment._internal(this._value); 984 const ScrollAlignment._internal(this._value);
994 toString() => 'ScrollAlignment.$_value'; 985 toString() => 'ScrollAlignment.$_value';
995 986
996 /// Attempt to align the element to the top of the scrollable area. 987 /// Attempt to align the element to the top of the scrollable area.
997 static const TOP = const ScrollAlignment._internal('TOP'); 988 static const TOP = const ScrollAlignment._internal('TOP');
998 /// Attempt to center the element in the scrollable area. 989 /// Attempt to center the element in the scrollable area.
999 static const CENTER = const ScrollAlignment._internal('CENTER'); 990 static const CENTER = const ScrollAlignment._internal('CENTER');
1000 /// Attempt to align the element to the bottom of the scrollable area. 991 /// Attempt to align the element to the bottom of the scrollable area.
1001 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 992 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1002 } 993 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698