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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Side-by-side diff isn't available for this file because of its large size.
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:
Download patch
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index de5270919dbedaf2cc0c94903757762773d9f9de..9485b48a048977af82ec86b0a05d4adec259c43d 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -7981,6 +7981,16 @@ class DomMimeTypeArray extends NativeFieldWrapperClass1 implements List<DomMimeT
throw new StateError("No elements");
}
+ DomMimeType get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ DomMimeType min([int compare(DomMimeType a, DomMimeType b)]) => _Collections.minInList(this, compare);
+
+ DomMimeType max([int compare(DomMimeType a, DomMimeType b)]) => _Collections.maxInList(this, compare);
+
DomMimeType removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -8195,6 +8205,16 @@ class DomPluginArray extends NativeFieldWrapperClass1 implements List<DomPlugin>
throw new StateError("No elements");
}
+ DomPlugin get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ DomPlugin min([int compare(DomPlugin a, DomPlugin b)]) => _Collections.minInList(this, compare);
+
+ DomPlugin max([int compare(DomPlugin a, DomPlugin b)]) => _Collections.maxInList(this, compare);
+
DomPlugin removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -8494,6 +8514,16 @@ class DomStringList extends NativeFieldWrapperClass1 implements List<String> {
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.");
}
@@ -8787,6 +8817,19 @@ class _ChildrenElementList implements List {
if (result == null) throw new StateError("No elements");
return result;
}
+
+ Element get single {
+ if (length > 1) throw new StateError("More than one element");
+ return first;
+ }
+
+ Element min([int compare(Element a, Element b)]) {
+ return _Collections.minInList(this, compare);
+ }
+
+ Element max([int compare(Element a, Element b)]) {
+ return _Collections.maxInList(this, compare);
+ }
}
// TODO(jacobr): this is an inefficient implementation but it is hard to see
@@ -8945,6 +8988,16 @@ class _FrozenElementList implements List {
Element get first => _nodeList.first;
Element get last => _nodeList.last;
+
+ Element get single => _nodeList.single;
+
+ Element min([int compare(Element a, Element b)]) {
+ return _Collections.minInList(this, compare);
+ }
+
+ Element max([int compare(Element a, Element b)]) {
+ return _Collections.maxInList(this, compare);
+ }
}
class _FrozenElementListIterator implements Iterator<Element> {
@@ -10743,6 +10796,16 @@ class FileList extends NativeFieldWrapperClass1 implements List<File> {
throw new StateError("No elements");
}
+ File get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ File min([int compare(File a, File b)]) => _Collections.minInList(this, compare);
+
+ File max([int compare(File a, File b)]) => _Collections.maxInList(this, compare);
+
File removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -11236,6 +11299,16 @@ class Float32Array extends ArrayBufferView implements List<num> {
throw new StateError("No elements");
}
+ num get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ num min([int compare(num a, num b)]) => _Collections.minInList(this, compare);
+
+ num max([int compare(num a, num b)]) => _Collections.maxInList(this, compare);
+
num removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -11419,6 +11492,16 @@ class Float64Array extends ArrayBufferView implements List<num> {
throw new StateError("No elements");
}
+ num get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ num min([int compare(num a, num b)]) => _Collections.minInList(this, compare);
+
+ num max([int compare(num a, num b)]) => _Collections.maxInList(this, compare);
+
num removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -12133,6 +12216,16 @@ class HtmlAllCollection extends NativeFieldWrapperClass1 implements List<Node> {
throw new StateError("No elements");
}
+ Node get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node min([int compare(Node a, Node b)]) => _Collections.minInList(this, compare);
+
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
+
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -12296,6 +12389,16 @@ class HtmlCollection extends NativeFieldWrapperClass1 implements List<Node> {
throw new StateError("No elements");
}
+ Node get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node min([int compare(Node a, Node b)]) => _Collections.minInList(this, compare);
+
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
+
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -14193,6 +14296,16 @@ class Int16Array extends ArrayBufferView implements List<int> {
throw new StateError("No elements");
}
+ int get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ int min([int compare(int a, int b)]) => _Collections.minInList(this, compare);
+
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
+
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -14376,6 +14489,16 @@ class Int32Array extends ArrayBufferView implements List<int> {
throw new StateError("No elements");
}
+ int get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ int min([int compare(int a, int b)]) => _Collections.minInList(this, compare);
+
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
+
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -14559,6 +14682,16 @@ class Int8Array extends ArrayBufferView implements List<int> {
throw new StateError("No elements");
}
+ int get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ int min([int compare(int a, int b)]) => _Collections.minInList(this, compare);
+
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
+
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -17586,6 +17719,16 @@ class NamedNodeMap extends NativeFieldWrapperClass1 implements List<Node> {
throw new StateError("No elements");
}
+ Node get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node min([int compare(Node a, Node b)]) => _Collections.minInList(this, compare);
+
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
+
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -17792,6 +17935,20 @@ class _ChildNodeListLazy implements List {
if (result == null) throw new StateError("No elements");
return result;
}
+ Node get single {
+ int l = this.length;
+ if (l == 0) throw new StateError("No elements");
+ if (l > 1) throw new StateError("More than one element");
+ return _this.$dom_firstChild;
+ }
+
+ Node min([int compare(Node a, Node b)]) {
+ return _Collections.minInList(this, compare);
+ }
+
+ Node max([int compare(Node a, Node b)]) {
+ return _Collections.maxInList(this, compare);
+ }
void add(Node value) {
_this.$dom_appendChild(value);
@@ -18336,6 +18493,16 @@ class NodeList extends NativeFieldWrapperClass1 implements List<Node> {
throw new StateError("No elements");
}
+ Node get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node min([int compare(Node a, Node b)]) => _Collections.minInList(this, compare);
+
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
+
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -21018,6 +21185,16 @@ class SourceBufferList extends EventTarget implements List<SourceBuffer> {
throw new StateError("No elements");
}
+ SourceBuffer get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SourceBuffer min([int compare(SourceBuffer a, SourceBuffer b)]) => _Collections.minInList(this, compare);
+
+ SourceBuffer max([int compare(SourceBuffer a, SourceBuffer b)]) => _Collections.maxInList(this, compare);
+
SourceBuffer removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -21273,6 +21450,16 @@ class SpeechGrammarList extends NativeFieldWrapperClass1 implements List<SpeechG
throw new StateError("No elements");
}
+ SpeechGrammar get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SpeechGrammar min([int compare(SpeechGrammar a, SpeechGrammar b)]) => _Collections.minInList(this, compare);
+
+ SpeechGrammar max([int compare(SpeechGrammar a, SpeechGrammar b)]) => _Collections.maxInList(this, compare);
+
SpeechGrammar removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -21824,6 +22011,16 @@ class SqlResultSetRowList extends NativeFieldWrapperClass1 implements List<Map>
throw new StateError("No elements");
}
+ Map get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Map min([int compare(Map a, Map b)]) => _Collections.minInList(this, compare);
+
+ Map max([int compare(Map a, Map b)]) => _Collections.maxInList(this, compare);
+
Map removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -23294,6 +23491,16 @@ class TextTrackCueList extends NativeFieldWrapperClass1 implements List<TextTrac
throw new StateError("No elements");
}
+ TextTrackCue get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ TextTrackCue min([int compare(TextTrackCue a, TextTrackCue b)]) => _Collections.minInList(this, compare);
+
+ TextTrackCue max([int compare(TextTrackCue a, TextTrackCue b)]) => _Collections.maxInList(this, compare);
+
TextTrackCue removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -23457,6 +23664,16 @@ class TextTrackList extends EventTarget implements List<TextTrack> {
throw new StateError("No elements");
}
+ TextTrack get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ TextTrack min([int compare(TextTrack a, TextTrack b)]) => _Collections.minInList(this, compare);
+
+ TextTrack max([int compare(TextTrack a, TextTrack b)]) => _Collections.maxInList(this, compare);
+
TextTrack removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -23784,6 +24001,16 @@ class TouchList extends NativeFieldWrapperClass1 implements List<Touch> {
throw new StateError("No elements");
}
+ Touch get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Touch min([int compare(Touch a, Touch b)]) => _Collections.minInList(this, compare);
+
+ Touch max([int compare(Touch a, Touch b)]) => _Collections.maxInList(this, compare);
+
Touch removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -24218,6 +24445,16 @@ class Uint16Array extends ArrayBufferView implements List<int> {
throw new StateError("No elements");
}
+ int get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ int min([int compare(int a, int b)]) => _Collections.minInList(this, compare);
+
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
+
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -24401,6 +24638,16 @@ class Uint32Array extends ArrayBufferView implements List<int> {
throw new StateError("No elements");
}
+ int get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ int min([int compare(int a, int b)]) => _Collections.minInList(this, compare);
+
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
+
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -24584,6 +24831,16 @@ class Uint8Array extends ArrayBufferView implements List<int> {
throw new StateError("No elements");
}
+ int get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ int min([int compare(int a, int b)]) => _Collections.minInList(this, compare);
+
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
+
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -27289,6 +27546,16 @@ class _ClientRectList extends NativeFieldWrapperClass1 implements List<ClientRec
throw new StateError("No elements");
}
+ ClientRect get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ ClientRect min([int compare(ClientRect a, ClientRect b)]) => _Collections.minInList(this, compare);
+
+ ClientRect max([int compare(ClientRect a, ClientRect b)]) => _Collections.maxInList(this, compare);
+
ClientRect removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -27452,6 +27719,16 @@ class _CssRuleList extends NativeFieldWrapperClass1 implements List<CssRule> {
throw new StateError("No elements");
}
+ CssRule get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ CssRule min([int compare(CssRule a, CssRule b)]) => _Collections.minInList(this, compare);
+
+ CssRule max([int compare(CssRule a, CssRule b)]) => _Collections.maxInList(this, compare);
+
CssRule removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -27607,6 +27884,16 @@ class _CssValueList extends CssValue implements List<CssValue> {
throw new StateError("No elements");
}
+ CssValue get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ CssValue min([int compare(CssValue a, CssValue b)]) => _Collections.minInList(this, compare);
+
+ CssValue max([int compare(CssValue a, CssValue b)]) => _Collections.maxInList(this, compare);
+
CssValue removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -27914,6 +28201,16 @@ class _EntryArray extends NativeFieldWrapperClass1 implements List<Entry> {
throw new StateError("No elements");
}
+ Entry get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Entry min([int compare(Entry a, Entry b)]) => _Collections.minInList(this, compare);
+
+ Entry max([int compare(Entry a, Entry b)]) => _Collections.maxInList(this, compare);
+
Entry removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -28069,6 +28366,16 @@ class _EntryArraySync extends NativeFieldWrapperClass1 implements List<EntrySync
throw new StateError("No elements");
}
+ EntrySync get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ EntrySync min([int compare(EntrySync a, EntrySync b)]) => _Collections.minInList(this, compare);
+
+ EntrySync max([int compare(EntrySync a, EntrySync b)]) => _Collections.maxInList(this, compare);
+
EntrySync removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -28256,6 +28563,16 @@ class _GamepadList extends NativeFieldWrapperClass1 implements List<Gamepad> {
throw new StateError("No elements");
}
+ Gamepad get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Gamepad min([int compare(Gamepad a, Gamepad b)]) => _Collections.minInList(this, compare);
+
+ Gamepad max([int compare(Gamepad a, Gamepad b)]) => _Collections.maxInList(this, compare);
+
Gamepad removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -28460,6 +28777,16 @@ class _MediaStreamList extends NativeFieldWrapperClass1 implements List<MediaStr
throw new StateError("No elements");
}
+ MediaStream get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ MediaStream min([int compare(MediaStream a, MediaStream b)]) => _Collections.minInList(this, compare);
+
+ MediaStream max([int compare(MediaStream a, MediaStream b)]) => _Collections.maxInList(this, compare);
+
MediaStream removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -28719,6 +29046,16 @@ class _SpeechInputResultList extends NativeFieldWrapperClass1 implements List<Sp
throw new StateError("No elements");
}
+ SpeechInputResult get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SpeechInputResult min([int compare(SpeechInputResult a, SpeechInputResult b)]) => _Collections.minInList(this, compare);
+
+ SpeechInputResult max([int compare(SpeechInputResult a, SpeechInputResult b)]) => _Collections.maxInList(this, compare);
+
SpeechInputResult removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -28882,6 +29219,16 @@ class _SpeechRecognitionResultList extends NativeFieldWrapperClass1 implements L
throw new StateError("No elements");
}
+ SpeechRecognitionResult get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SpeechRecognitionResult min([int compare(SpeechRecognitionResult a, SpeechRecognitionResult b)]) => _Collections.minInList(this, compare);
+
+ SpeechRecognitionResult max([int compare(SpeechRecognitionResult a, SpeechRecognitionResult b)]) => _Collections.maxInList(this, compare);
+
SpeechRecognitionResult removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -29037,6 +29384,16 @@ class _StyleSheetList extends NativeFieldWrapperClass1 implements List<StyleShee
throw new StateError("No elements");
}
+ StyleSheet get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ StyleSheet min([int compare(StyleSheet a, StyleSheet b)]) => _Collections.minInList(this, compare);
+
+ StyleSheet max([int compare(StyleSheet a, StyleSheet b)]) => _Collections.maxInList(this, compare);
+
StyleSheet removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}
@@ -29200,6 +29557,16 @@ class _WebKitAnimationList extends NativeFieldWrapperClass1 implements List<Anim
throw new StateError("No elements");
}
+ Animation get single {
+ if (length == 1) return this[0];
+ if (length == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Animation min([int compare(Animation a, Animation b)]) => _Collections.minInList(this, compare);
+
+ Animation max([int compare(Animation a, Animation b)]) => _Collections.maxInList(this, compare);
+
Animation removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
}

Powered by Google App Engine
This is Rietveld 408576698