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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/tree/nodes.dart

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. 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 tree; 5 part of tree;
6 6
7 abstract class Visitor<R> { 7 abstract class Visitor<R> {
8 const Visitor(); 8 const Visitor();
9 9
10 R visitNode(Node node); 10 R visitNode(Node node);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 534 }
535 535
536 Node get last { 536 Node get last {
537 return Collections.last(this); 537 return Collections.last(this);
538 } 538 }
539 539
540 Node get single { 540 Node get single {
541 return Collections.single(this); 541 return Collections.single(this);
542 } 542 }
543 543
544 Node min([int compare(Node a, Node b)]) => Collections.min(this, compare);
545
546 Node max([int compare(Node a, Node b)]) => Collections.max(this, compare);
547
544 Node firstMatching(bool test(Node value), {Node orElse()}) { 548 Node firstMatching(bool test(Node value), {Node orElse()}) {
545 return Collections.firstMatching(this, test, orElse); 549 return Collections.firstMatching(this, test, orElse);
546 } 550 }
547 551
548 Node lastMatching(bool test(Node value), {Node orElse()}) { 552 Node lastMatching(bool test(Node value), {Node orElse()}) {
549 return Collections.lastMatching(this, test, orElse); 553 return Collections.lastMatching(this, test, orElse);
550 } 554 }
551 555
552 Node singleMatching(bool test(Node value)) { 556 Node singleMatching(bool test(Node value)) {
553 return Collections.singleMatching(this, test); 557 return Collections.singleMatching(this, test);
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 * argument). 2089 * argument).
2086 * 2090 *
2087 * TODO(ahe): This method is controversial, the team needs to discuss 2091 * TODO(ahe): This method is controversial, the team needs to discuss
2088 * if top-level methods are acceptable and what naming conventions to 2092 * if top-level methods are acceptable and what naming conventions to
2089 * use. 2093 * use.
2090 */ 2094 */
2091 initializerDo(Node node, f(Node node)) { 2095 initializerDo(Node node, f(Node node)) {
2092 SendSet send = node.asSendSet(); 2096 SendSet send = node.asSendSet();
2093 if (send != null) return f(send.arguments.head); 2097 if (send != null) return f(send.arguments.head);
2094 } 2098 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698