Chromium Code Reviews

Side by Side Diff: sdk/lib/html/templates/html/impl/impl_Node.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: Address review comments. Fix T->E in Iterable. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | 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 html; 5 part of html;
6 6
7 /** 7 /**
8 * Lazy implementation of the child nodes of an element that does not request 8 * Lazy implementation of the child nodes of an element that does not request
9 * the actual child nodes of an element until strictly necessary greatly 9 * the actual child nodes of an element until strictly necessary greatly
10 * improving performance for the typical cases where it is not required. 10 * improving performance for the typical cases where it is not required.
(...skipping 33 matching lines...)
44 return result; 44 return result;
45 } 45 }
46 Node get single { 46 Node get single {
47 int l = this.length; 47 int l = this.length;
48 if (l == 0) throw new StateError("No elements"); 48 if (l == 0) throw new StateError("No elements");
49 if (l > 1) throw new StateError("More than one element"); 49 if (l > 1) throw new StateError("More than one element");
50 return _this.$dom_firstChild; 50 return _this.$dom_firstChild;
51 } 51 }
52 $endif 52 $endif
53 53
54 Node min([int compare(Node a, Node b)]) {
55 return _Collections.minInList(this, compare);
56 }
57
58 Node max([int compare(Node a, Node b)]) {
59 return _Collections.maxInList(this, compare);
60 }
61
54 void add(Node value) { 62 void add(Node value) {
55 _this.$dom_appendChild(value); 63 _this.$dom_appendChild(value);
56 } 64 }
57 65
58 void addLast(Node value) { 66 void addLast(Node value) {
59 _this.$dom_appendChild(value); 67 _this.$dom_appendChild(value);
60 } 68 }
61 69
62 70
63 void addAll(Iterable<Node> iterable) { 71 void addAll(Iterable<Node> iterable) {
(...skipping 169 matching lines...)
233 final Node parent = this.parentNode; 241 final Node parent = this.parentNode;
234 parent.$dom_replaceChild(otherNode, this); 242 parent.$dom_replaceChild(otherNode, this);
235 } catch (e) { 243 } catch (e) {
236 244
237 }; 245 };
238 return this; 246 return this;
239 } 247 }
240 248
241 $!MEMBERS 249 $!MEMBERS
242 } 250 }
OLDNEW

Powered by Google App Engine