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

Unified Diff: sdk/lib/svg/dart2js/svg_dart2js.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: Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/svg/dart2js/svg_dart2js.dart
diff --git a/sdk/lib/svg/dart2js/svg_dart2js.dart b/sdk/lib/svg/dart2js/svg_dart2js.dart
index 9f9906d109cbdbd9dcd2b96b0033ad13806bc633..c05cd565b0b03281551ac3546726552a1e410e32 100644
--- a/sdk/lib/svg/dart2js/svg_dart2js.dart
+++ b/sdk/lib/svg/dart2js/svg_dart2js.dart
@@ -2897,6 +2897,16 @@ class LengthList implements JavaScriptIndexingBehavior, List<Length> native "*SV
throw new StateError("No elements");
}
+ Length get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Length min([int compare(Length a, Length b)]) => _Collections.minInList(this, compare);
Anders Johnsen 2013/01/02 11:04:05 Where is minInList defined?
Lasse Reichstein Nielsen 2013/01/02 11:49:33 in _Collections! :P It's a helper class in _Collec
+
+ Length max([int compare(Length a, Length b)]) => _Collections.maxInList(this, compare);
+
Length removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -3458,6 +3468,16 @@ class NumberList implements JavaScriptIndexingBehavior, List<Number> native "*SV
throw new StateError("No elements");
}
+ Number get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Number min([int compare(Number a, Number b)]) => _Collections.minInList(this, compare);
+
+ Number max([int compare(Number a, Number b)]) => _Collections.maxInList(this, compare);
+
Number removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -4194,6 +4214,16 @@ class PathSegList implements JavaScriptIndexingBehavior, List<PathSeg> native "*
throw new StateError("No elements");
}
+ PathSeg get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ PathSeg min([int compare(PathSeg a, PathSeg b)]) => _Collections.minInList(this, compare);
+
+ PathSeg max([int compare(PathSeg a, PathSeg b)]) => _Collections.maxInList(this, compare);
+
PathSeg removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -4955,6 +4985,16 @@ class StringList implements JavaScriptIndexingBehavior, List<String> native "*SV
throw new StateError("No elements");
}
+ String get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ String min([int compare(String a, String b)]) => _Collections.minInList(this, compare);
+
+ String max([int compare(String a, String b)]) => _Collections.maxInList(this, compare);
+
String removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -5984,6 +6024,16 @@ class TransformList implements List<Transform>, JavaScriptIndexingBehavior nativ
throw new StateError("No elements");
}
+ Transform get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Transform min([int compare(Transform a, Transform b)]) => _Collections.minInList(this, compare);
+
+ Transform max([int compare(Transform a, Transform b)]) => _Collections.maxInList(this, compare);
+
Transform removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -6427,6 +6477,16 @@ class _ElementInstanceList implements JavaScriptIndexingBehavior, List<ElementIn
throw new StateError("No elements");
}
+ ElementInstance get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ ElementInstance min([int compare(ElementInstance a, ElementInstance b)]) => _Collections.minInList(this, compare);
+
+ ElementInstance max([int compare(ElementInstance a, ElementInstance b)]) => _Collections.maxInList(this, compare);
+
ElementInstance removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}

Powered by Google App Engine
This is Rietveld 408576698