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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/crypto/sha256.dart ('k') | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 5e169881d3a5889652485ba975ca5a6e0c53be93..0ba229ef20e393cf347f9572407680aaf1c8b9cb 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -1,10 +1,11 @@
library html;
+import 'dart:async';
import 'dart:collection';
import 'dart:html_common';
import 'dart:indexed_db';
import 'dart:isolate';
-import 'dart:json';
+import 'dart:json' as json;
import 'dart:math';
import 'dart:svg' as svg;
import 'dart:web_audio' as web_audio;
@@ -5999,7 +6000,7 @@ class Document extends Node native "*Document"
final mutableMatches = $dom_getElementsByName(
selectors.substring(7,selectors.length - 2));
int len = mutableMatches.length;
- final copyOfMatches = new List<Element>(len);
+ final copyOfMatches = new List<Element>.fixedLength(len);
for (int i = 0; i < len; ++i) {
copyOfMatches[i] = mutableMatches[i];
}
@@ -6007,7 +6008,7 @@ class Document extends Node native "*Document"
} else if (new RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) {
final mutableMatches = $dom_getElementsByTagName(selectors);
int len = mutableMatches.length;
- final copyOfMatches = new List<Element>(len);
+ final copyOfMatches = new List<Element>.fixedLength(len);
for (int i = 0; i < len; ++i) {
copyOfMatches[i] = mutableMatches[i];
}
@@ -6494,27 +6495,13 @@ class DomMimeTypeArray implements JavaScriptIndexingBehavior, List<DomMimeType>
// From Iterable<DomMimeType>:
- Iterator<DomMimeType> iterator() {
+ Iterator<DomMimeType> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<DomMimeType>(this);
}
- // From Collection<DomMimeType>:
-
- void add(DomMimeType value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(DomMimeType value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<DomMimeType> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, DomMimeType)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -6523,17 +6510,60 @@ class DomMimeTypeArray implements JavaScriptIndexingBehavior, List<DomMimeType>
void forEach(void f(DomMimeType element)) => Collections.forEach(this, f);
- Collection map(f(DomMimeType element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(DomMimeType element)) => new MappedList<DomMimeType, dynamic>(this, f);
- Collection<DomMimeType> filter(bool f(DomMimeType element)) =>
- Collections.filter(this, <DomMimeType>[], f);
+ Iterable<DomMimeType> where(bool f(DomMimeType element)) => new WhereIterable<DomMimeType>(this, f);
bool every(bool f(DomMimeType element)) => Collections.every(this, f);
- bool some(bool f(DomMimeType element)) => Collections.some(this, f);
+ bool any(bool f(DomMimeType element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<DomMimeType> take(int n) => new ListView<DomMimeType>(this, 0, n);
+
+ Iterable<DomMimeType> takeWhile(bool test(DomMimeType value)) {
+ return new TakeWhileIterable<DomMimeType>(this, test);
+ }
+
+ List<DomMimeType> skip(int n) => new ListView<DomMimeType>(this, n, null);
+
+ Iterable<DomMimeType> skipWhile(bool test(DomMimeType value)) {
+ return new SkipWhileIterable<DomMimeType>(this, test);
+ }
+
+ DomMimeType firstMatching(bool test(DomMimeType value), { DomMimeType orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ DomMimeType lastMatching(bool test(DomMimeType value), {DomMimeType orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ DomMimeType singleMatching(bool test(DomMimeType value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ DomMimeType elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<DomMimeType>:
+
+ void add(DomMimeType value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(DomMimeType value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<DomMimeType> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<DomMimeType>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -6555,9 +6585,25 @@ class DomMimeTypeArray implements JavaScriptIndexingBehavior, List<DomMimeType>
return Lists.lastIndexOf(this, element, start);
}
- DomMimeType get first => this[0];
+ DomMimeType get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ DomMimeType get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ DomMimeType max([int compare(DomMimeType a, DomMimeType b)]) => _Collections.maxInList(this, compare);
DomMimeType removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -6652,27 +6698,13 @@ class DomPluginArray implements JavaScriptIndexingBehavior, List<DomPlugin> nati
// From Iterable<DomPlugin>:
- Iterator<DomPlugin> iterator() {
+ Iterator<DomPlugin> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<DomPlugin>(this);
}
- // From Collection<DomPlugin>:
-
- void add(DomPlugin value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(DomPlugin value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<DomPlugin> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, DomPlugin)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -6681,17 +6713,60 @@ class DomPluginArray implements JavaScriptIndexingBehavior, List<DomPlugin> nati
void forEach(void f(DomPlugin element)) => Collections.forEach(this, f);
- Collection map(f(DomPlugin element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<DomPlugin> filter(bool f(DomPlugin element)) =>
- Collections.filter(this, <DomPlugin>[], f);
+ List mappedBy(f(DomPlugin element)) => new MappedList<DomPlugin, dynamic>(this, f);
+
+ Iterable<DomPlugin> where(bool f(DomPlugin element)) => new WhereIterable<DomPlugin>(this, f);
bool every(bool f(DomPlugin element)) => Collections.every(this, f);
- bool some(bool f(DomPlugin element)) => Collections.some(this, f);
+ bool any(bool f(DomPlugin element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<DomPlugin> take(int n) => new ListView<DomPlugin>(this, 0, n);
+
+ Iterable<DomPlugin> takeWhile(bool test(DomPlugin value)) {
+ return new TakeWhileIterable<DomPlugin>(this, test);
+ }
+
+ List<DomPlugin> skip(int n) => new ListView<DomPlugin>(this, n, null);
+
+ Iterable<DomPlugin> skipWhile(bool test(DomPlugin value)) {
+ return new SkipWhileIterable<DomPlugin>(this, test);
+ }
+
+ DomPlugin firstMatching(bool test(DomPlugin value), { DomPlugin orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ DomPlugin lastMatching(bool test(DomPlugin value), {DomPlugin orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ DomPlugin singleMatching(bool test(DomPlugin value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ DomPlugin elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<DomPlugin>:
+
+ void add(DomPlugin value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(DomPlugin value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<DomPlugin> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<DomPlugin>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -6713,9 +6788,25 @@ class DomPluginArray implements JavaScriptIndexingBehavior, List<DomPlugin> nati
return Lists.lastIndexOf(this, element, start);
}
- DomPlugin get first => this[0];
+ DomPlugin get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ DomPlugin get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ DomPlugin max([int compare(DomPlugin a, DomPlugin b)]) => _Collections.maxInList(this, compare);
DomPlugin removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -6869,27 +6960,13 @@ class DomStringList implements JavaScriptIndexingBehavior, List<String> native "
// From Iterable<String>:
- Iterator<String> iterator() {
+ Iterator<String> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<String>(this);
}
- // From Collection<String>:
-
- void add(String value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(String value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<String> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, String)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -6898,17 +6975,60 @@ class DomStringList implements JavaScriptIndexingBehavior, List<String> native "
void forEach(void f(String element)) => Collections.forEach(this, f);
- Collection map(f(String element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(String element)) => new MappedList<String, dynamic>(this, f);
- Collection<String> filter(bool f(String element)) =>
- Collections.filter(this, <String>[], f);
+ Iterable<String> where(bool f(String element)) => new WhereIterable<String>(this, f);
bool every(bool f(String element)) => Collections.every(this, f);
- bool some(bool f(String element)) => Collections.some(this, f);
+ bool any(bool f(String element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<String> take(int n) => new ListView<String>(this, 0, n);
+
+ Iterable<String> takeWhile(bool test(String value)) {
+ return new TakeWhileIterable<String>(this, test);
+ }
+
+ List<String> skip(int n) => new ListView<String>(this, n, null);
+
+ Iterable<String> skipWhile(bool test(String value)) {
+ return new SkipWhileIterable<String>(this, test);
+ }
+
+ String firstMatching(bool test(String value), { String orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ String lastMatching(bool test(String value), {String orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ String singleMatching(bool test(String value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ String elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<String>:
+
+ void add(String value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(String value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<String> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<String>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -6930,9 +7050,25 @@ class DomStringList implements JavaScriptIndexingBehavior, List<String> native "
return Lists.lastIndexOf(this, element, start);
}
- String get first => this[0];
+ String get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ String get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ String max([int compare(String a, String b)]) => _Collections.maxInList(this, compare);
String removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -7012,14 +7148,22 @@ class _ChildrenElementList implements List {
: _childElements = element.$dom_children,
_element = element;
- List<Element> _toList() {
- final output = new List(_childElements.length);
+ List<Element> toList() {
+ final output = new List<Element>.fixedLength(_childElements.length);
for (int i = 0, len = _childElements.length; i < len; i++) {
output[i] = _childElements[i];
}
return output;
}
+ Set<Element> toSet() {
+ final output = new Set<Element>(_childElements.length);
+ for (int i = 0, len = _childElements.length; i < len; i++) {
+ output.add(_childElements[i]);
+ }
+ return output;
+ }
+
bool contains(Element element) => _childElements.contains(element);
void forEach(void f(Element element)) {
@@ -7028,46 +7172,71 @@ class _ChildrenElementList implements List {
}
}
- List<Element> filter(bool f(Element element)) {
- final output = [];
- forEach((Element element) {
- if (f(element)) {
- output.add(element);
- }
- });
- return new _FrozenElementList._wrap(output);
- }
-
bool every(bool f(Element element)) {
for (Element element in this) {
if (!f(element)) {
return false;
}
- };
+ }
return true;
}
- bool some(bool f(Element element)) {
+ bool any(bool f(Element element)) {
for (Element element in this) {
if (f(element)) {
return true;
}
- };
+ }
return false;
}
- Collection map(f(Element element)) {
- final out = [];
- for (Element el in this) {
- out.add(f(el));
- }
- return out;
+ String join([String separator]) {
+ return Collections.joinList(this, separator);
+ }
+
+ List mappedBy(f(Element element)) {
+ return new MappedList<Element, dynamic>(this, f);
}
+ Iterable<Element> where(bool f(Element element))
+ => new WhereIterable<Element>(this, f);
+
bool get isEmpty {
return _element.$dom_firstElementChild == null;
}
+ List<Element> take(int n) {
+ return new ListView<Element>(this, 0, n);
+ }
+
+ Iterable<Element> takeWhile(bool test(Element value)) {
+ return new TakeWhileIterable<Element>(this, test);
+ }
+
+ List<Element> skip(int n) {
+ return new ListView<Element>(this, n, null);
+ }
+
+ Iterable<Element> skipWhile(bool test(Element value)) {
+ return new SkipWhileIterable<Element>(this, test);
+ }
+
+ Element firstMatching(bool test(Element value), {Element orElse()}) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Element lastMatching(bool test(Element value), {Element orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Element singleMatching(bool test(Element value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Element elementAt(int index) {
+ return this[index];
+ }
+
int get length {
return _childElements.length;
}
@@ -7092,10 +7261,10 @@ class _ChildrenElementList implements List {
Element addLast(Element value) => add(value);
- Iterator<Element> iterator() => _toList().iterator();
+ Iterator<Element> get iterator => toList().iterator;
- void addAll(Collection<Element> collection) {
- for (Element element in collection) {
+ void addAll(Iterable<Element> iterable) {
+ for (Element element in iterable) {
_element.$dom_appendChild(element);
}
}
@@ -7156,12 +7325,29 @@ class _ChildrenElementList implements List {
}
Element get first {
- return _element.$dom_firstElementChild;
+ Element result = _element.$dom_firstElementChild;
+ if (result == null) throw new StateError("No elements");
+ return result;
}
Element get last {
- return _element.$dom_lastElementChild;
+ Element result = _element.$dom_lastElementChild;
+ 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);
}
}
@@ -7187,22 +7373,17 @@ class _FrozenElementList implements List {
}
}
- Collection map(f(Element element)) {
- final out = [];
- for (Element el in this) {
- out.add(f(el));
- }
- return out;
+ String join([String separator]) {
+ return Collections.joinList(this, separator);
}
- List<Element> filter(bool f(Element element)) {
- final out = [];
- for (Element el in this) {
- if (f(el)) out.add(el);
- }
- return out;
+ List mappedBy(f(Element element)) {
+ return new MappedList<Element, dynamic>(this, f);
}
+ Iterable<Element> where(bool f(Element element))
+ => new WhereIterable<Element>(this, f);
+
bool every(bool f(Element element)) {
for(Element element in this) {
if (!f(element)) {
@@ -7212,7 +7393,7 @@ class _FrozenElementList implements List {
return true;
}
- bool some(bool f(Element element)) {
+ bool any(bool f(Element element)) {
for(Element element in this) {
if (f(element)) {
return true;
@@ -7221,6 +7402,38 @@ class _FrozenElementList implements List {
return false;
}
+ List<Element> take(int n) {
+ return new ListView<Element>(this, 0, n);
+ }
+
+ Iterable<Element> takeWhile(bool test(T value)) {
+ return new TakeWhileIterable<Element>(this, test);
+ }
+
+ List<Element> skip(int n) {
+ return new ListView<Element>(this, n, null);
+ }
+
+ Iterable<Element> skipWhile(bool test(T value)) {
+ return new SkipWhileIterable<Element>(this, test);
+ }
+
+ Element firstMatching(bool test(Element value), {Element orElse()}) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Element lastMatching(bool test(Element value), {Element orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Element singleMatching(bool test(Element value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Element elementAt(int index) {
+ return this[index];
+ }
+
bool get isEmpty => _nodeList.isEmpty;
int get length => _nodeList.length;
@@ -7243,9 +7456,9 @@ class _FrozenElementList implements List {
throw new UnsupportedError('');
}
- Iterator<Element> iterator() => new _FrozenElementListIterator(this);
+ Iterator<Element> get iterator => new _FrozenElementListIterator(this);
- void addAll(Collection<Element> collection) {
+ void addAll(Iterable<Element> iterable) {
throw new UnsupportedError('');
}
@@ -7294,6 +7507,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> {
@@ -7303,21 +7526,28 @@ class _FrozenElementListIterator implements Iterator<Element> {
_FrozenElementListIterator(this._list);
/**
- * Gets the next element in the iteration. Throws a
- * [StateError("No more elements")] if no element is left.
+ * Moves to the next element. Returns true if the iterator is positioned
+ * at an element. Returns false if it is positioned after the last element.
*/
- Element next() {
- if (!hasNext) {
- throw new StateError("No more elements");
+ bool moveNext() {
+ int nextIndex = _index + 1;
+ if (nextIndex < _list.length) {
+ _current = _list[nextIndex];
+ _index = nextIndex;
+ return true;
}
-
- return _list[_index++];
+ _index = _list.length;
+ _current = null;
+ return false;
}
/**
- * Returns whether the [Iterator] has elements left.
+ * Returns the element the [Iterator] is positioned at.
+ *
+ * Return [:null:] if the iterator is positioned before the first, or
+ * after the last element.
*/
- bool get hasNext => _index < _list.length;
+ E get current => _current;
}
class _ElementCssClassSet extends CssClassSet {
@@ -7341,7 +7571,7 @@ class _ElementCssClassSet extends CssClassSet {
void writeClasses(Set<String> s) {
List list = new List.from(s);
- _element.$dom_className = Strings.join(list, ' ');
+ _element.$dom_className = s.join(' ');
}
}
@@ -8847,27 +9077,13 @@ class FileList implements JavaScriptIndexingBehavior, List<File> native "*FileLi
// From Iterable<File>:
- Iterator<File> iterator() {
+ Iterator<File> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<File>(this);
}
- // From Collection<File>:
-
- void add(File value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(File value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<File> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, File)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -8876,17 +9092,60 @@ class FileList implements JavaScriptIndexingBehavior, List<File> native "*FileLi
void forEach(void f(File element)) => Collections.forEach(this, f);
- Collection map(f(File element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(File element)) => new MappedList<File, dynamic>(this, f);
- Collection<File> filter(bool f(File element)) =>
- Collections.filter(this, <File>[], f);
+ Iterable<File> where(bool f(File element)) => new WhereIterable<File>(this, f);
bool every(bool f(File element)) => Collections.every(this, f);
- bool some(bool f(File element)) => Collections.some(this, f);
+ bool any(bool f(File element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<File> take(int n) => new ListView<File>(this, 0, n);
+
+ Iterable<File> takeWhile(bool test(File value)) {
+ return new TakeWhileIterable<File>(this, test);
+ }
+
+ List<File> skip(int n) => new ListView<File>(this, n, null);
+
+ Iterable<File> skipWhile(bool test(File value)) {
+ return new SkipWhileIterable<File>(this, test);
+ }
+
+ File firstMatching(bool test(File value), { File orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ File lastMatching(bool test(File value), {File orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ File singleMatching(bool test(File value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ File elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<File>:
+
+ void add(File value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(File value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<File> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<File>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -8908,9 +9167,25 @@ class FileList implements JavaScriptIndexingBehavior, List<File> native "*FileLi
return Lists.lastIndexOf(this, element, start);
}
- File get first => this[0];
+ File get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
- File get last => this[length - 1];
+ File get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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.");
@@ -9223,27 +9498,13 @@ class Float32Array extends ArrayBufferView implements JavaScriptIndexingBehavior
// From Iterable<num>:
- Iterator<num> iterator() {
+ Iterator<num> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<num>(this);
}
- // From Collection<num>:
-
- void add(num value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(num value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<num> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, num)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -9252,17 +9513,60 @@ class Float32Array extends ArrayBufferView implements JavaScriptIndexingBehavior
void forEach(void f(num element)) => Collections.forEach(this, f);
- Collection map(f(num element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<num> filter(bool f(num element)) =>
- Collections.filter(this, <num>[], f);
+ List mappedBy(f(num element)) => new MappedList<num, dynamic>(this, f);
+
+ Iterable<num> where(bool f(num element)) => new WhereIterable<num>(this, f);
bool every(bool f(num element)) => Collections.every(this, f);
- bool some(bool f(num element)) => Collections.some(this, f);
+ bool any(bool f(num element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<num> take(int n) => new ListView<num>(this, 0, n);
+
+ Iterable<num> takeWhile(bool test(num value)) {
+ return new TakeWhileIterable<num>(this, test);
+ }
+
+ List<num> skip(int n) => new ListView<num>(this, n, null);
+
+ Iterable<num> skipWhile(bool test(num value)) {
+ return new SkipWhileIterable<num>(this, test);
+ }
+
+ num firstMatching(bool test(num value), { num orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ num lastMatching(bool test(num value), {num orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ num singleMatching(bool test(num value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ num elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<num>:
+
+ void add(num value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(num value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<num> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<num>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -9284,9 +9588,25 @@ class Float32Array extends ArrayBufferView implements JavaScriptIndexingBehavior
return Lists.lastIndexOf(this, element, start);
}
- num get first => this[0];
+ num get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ num get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ num max([int compare(num a, num b)]) => _Collections.maxInList(this, compare);
num removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -9349,27 +9669,13 @@ class Float64Array extends ArrayBufferView implements JavaScriptIndexingBehavior
// From Iterable<num>:
- Iterator<num> iterator() {
+ Iterator<num> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<num>(this);
}
- // From Collection<num>:
-
- void add(num value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(num value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<num> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, num)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -9378,17 +9684,60 @@ class Float64Array extends ArrayBufferView implements JavaScriptIndexingBehavior
void forEach(void f(num element)) => Collections.forEach(this, f);
- Collection map(f(num element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(num element)) => new MappedList<num, dynamic>(this, f);
- Collection<num> filter(bool f(num element)) =>
- Collections.filter(this, <num>[], f);
+ Iterable<num> where(bool f(num element)) => new WhereIterable<num>(this, f);
bool every(bool f(num element)) => Collections.every(this, f);
- bool some(bool f(num element)) => Collections.some(this, f);
+ bool any(bool f(num element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<num> take(int n) => new ListView<num>(this, 0, n);
+
+ Iterable<num> takeWhile(bool test(num value)) {
+ return new TakeWhileIterable<num>(this, test);
+ }
+
+ List<num> skip(int n) => new ListView<num>(this, n, null);
+
+ Iterable<num> skipWhile(bool test(num value)) {
+ return new SkipWhileIterable<num>(this, test);
+ }
+
+ num firstMatching(bool test(num value), { num orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ num lastMatching(bool test(num value), {num orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ num singleMatching(bool test(num value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ num elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<num>:
+
+ void add(num value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(num value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<num> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<num>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -9410,9 +9759,25 @@ class Float64Array extends ArrayBufferView implements JavaScriptIndexingBehavior
return Lists.lastIndexOf(this, element, start);
}
- num get first => this[0];
+ num get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ num get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ num max([int compare(num a, num b)]) => _Collections.maxInList(this, compare);
num removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -9835,27 +10200,13 @@ class HtmlAllCollection implements JavaScriptIndexingBehavior, List<Node> native
// From Iterable<Node>:
- Iterator<Node> iterator() {
+ Iterator<Node> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Node>(this);
}
- // From Collection<Node>:
-
- void add(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Node> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -9864,17 +10215,60 @@ class HtmlAllCollection implements JavaScriptIndexingBehavior, List<Node> native
void forEach(void f(Node element)) => Collections.forEach(this, f);
- Collection map(f(Node element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<Node> filter(bool f(Node element)) =>
- Collections.filter(this, <Node>[], f);
+ List mappedBy(f(Node element)) => new MappedList<Node, dynamic>(this, f);
+
+ Iterable<Node> where(bool f(Node element)) => new WhereIterable<Node>(this, f);
bool every(bool f(Node element)) => Collections.every(this, f);
- bool some(bool f(Node element)) => Collections.some(this, f);
+ bool any(bool f(Node element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Node> take(int n) => new ListView<Node>(this, 0, n);
+
+ Iterable<Node> takeWhile(bool test(Node value)) {
+ return new TakeWhileIterable<Node>(this, test);
+ }
+
+ List<Node> skip(int n) => new ListView<Node>(this, n, null);
+
+ Iterable<Node> skipWhile(bool test(Node value)) {
+ return new SkipWhileIterable<Node>(this, test);
+ }
+
+ Node firstMatching(bool test(Node value), { Node orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Node lastMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Node singleMatching(bool test(Node value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Node>:
+
+ void add(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Node> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Node>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -9896,9 +10290,25 @@ class HtmlAllCollection implements JavaScriptIndexingBehavior, List<Node> native
return Lists.lastIndexOf(this, element, start);
}
- Node get first => this[0];
+ Node get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -9956,27 +10366,13 @@ class HtmlCollection implements JavaScriptIndexingBehavior, List<Node> native "*
// From Iterable<Node>:
- Iterator<Node> iterator() {
+ Iterator<Node> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Node>(this);
}
- // From Collection<Node>:
-
- void add(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Node> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -9985,17 +10381,60 @@ class HtmlCollection implements JavaScriptIndexingBehavior, List<Node> native "*
void forEach(void f(Node element)) => Collections.forEach(this, f);
- Collection map(f(Node element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(Node element)) => new MappedList<Node, dynamic>(this, f);
- Collection<Node> filter(bool f(Node element)) =>
- Collections.filter(this, <Node>[], f);
+ Iterable<Node> where(bool f(Node element)) => new WhereIterable<Node>(this, f);
bool every(bool f(Node element)) => Collections.every(this, f);
- bool some(bool f(Node element)) => Collections.some(this, f);
+ bool any(bool f(Node element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Node> take(int n) => new ListView<Node>(this, 0, n);
+
+ Iterable<Node> takeWhile(bool test(Node value)) {
+ return new TakeWhileIterable<Node>(this, test);
+ }
+
+ List<Node> skip(int n) => new ListView<Node>(this, n, null);
+
+ Iterable<Node> skipWhile(bool test(Node value)) {
+ return new SkipWhileIterable<Node>(this, test);
+ }
+
+ Node firstMatching(bool test(Node value), { Node orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Node lastMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Node singleMatching(bool test(Node value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Node>:
+
+ void add(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Node> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Node>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -10017,9 +10456,25 @@ class HtmlCollection implements JavaScriptIndexingBehavior, List<Node> native "*
return Lists.lastIndexOf(this, element, start);
}
- Node get first => this[0];
+ Node get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -11582,27 +12037,13 @@ class Int16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
// From Iterable<int>:
- Iterator<int> iterator() {
+ Iterator<int> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<int>(this);
}
- // From Collection<int>:
-
- void add(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<int> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -11611,17 +12052,60 @@ class Int16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => Collections.forEach(this, f);
- Collection map(f(int element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<int> filter(bool f(int element)) =>
- Collections.filter(this, <int>[], f);
+ List mappedBy(f(int element)) => new MappedList<int, dynamic>(this, f);
+
+ Iterable<int> where(bool f(int element)) => new WhereIterable<int>(this, f);
bool every(bool f(int element)) => Collections.every(this, f);
- bool some(bool f(int element)) => Collections.some(this, f);
+ bool any(bool f(int element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<int> take(int n) => new ListView<int>(this, 0, n);
+
+ Iterable<int> takeWhile(bool test(int value)) {
+ return new TakeWhileIterable<int>(this, test);
+ }
+
+ List<int> skip(int n) => new ListView<int>(this, n, null);
+
+ Iterable<int> skipWhile(bool test(int value)) {
+ return new SkipWhileIterable<int>(this, test);
+ }
+
+ int firstMatching(bool test(int value), { int orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ int lastMatching(bool test(int value), {int orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ int singleMatching(bool test(int value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ int elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<int>:
+
+ void add(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<int> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<int>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -11643,9 +12127,25 @@ class Int16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
return Lists.lastIndexOf(this, element, start);
}
- int get first => this[0];
+ int get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ int get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -11708,27 +12208,13 @@ class Int32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
// From Iterable<int>:
- Iterator<int> iterator() {
+ Iterator<int> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<int>(this);
}
- // From Collection<int>:
-
- void add(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<int> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -11737,19 +12223,62 @@ class Int32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => Collections.forEach(this, f);
- Collection map(f(int element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(int element)) => new MappedList<int, dynamic>(this, f);
- Collection<int> filter(bool f(int element)) =>
- Collections.filter(this, <int>[], f);
+ Iterable<int> where(bool f(int element)) => new WhereIterable<int>(this, f);
bool every(bool f(int element)) => Collections.every(this, f);
- bool some(bool f(int element)) => Collections.some(this, f);
+ bool any(bool f(int element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
- // From List<int>:
- void set length(int value) {
+ List<int> take(int n) => new ListView<int>(this, 0, n);
+
+ Iterable<int> takeWhile(bool test(int value)) {
+ return new TakeWhileIterable<int>(this, test);
+ }
+
+ List<int> skip(int n) => new ListView<int>(this, n, null);
+
+ Iterable<int> skipWhile(bool test(int value)) {
+ return new SkipWhileIterable<int>(this, test);
+ }
+
+ int firstMatching(bool test(int value), { int orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ int lastMatching(bool test(int value), {int orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ int singleMatching(bool test(int value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ int elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<int>:
+
+ void add(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<int> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ // From List<int>:
+ void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
}
@@ -11769,9 +12298,25 @@ class Int32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
return Lists.lastIndexOf(this, element, start);
}
- int get first => this[0];
+ int get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ int get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -11834,27 +12379,13 @@ class Int8Array extends ArrayBufferView implements JavaScriptIndexingBehavior, L
// From Iterable<int>:
- Iterator<int> iterator() {
+ Iterator<int> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<int>(this);
}
- // From Collection<int>:
-
- void add(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<int> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -11863,17 +12394,60 @@ class Int8Array extends ArrayBufferView implements JavaScriptIndexingBehavior, L
void forEach(void f(int element)) => Collections.forEach(this, f);
- Collection map(f(int element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<int> filter(bool f(int element)) =>
- Collections.filter(this, <int>[], f);
+ List mappedBy(f(int element)) => new MappedList<int, dynamic>(this, f);
+
+ Iterable<int> where(bool f(int element)) => new WhereIterable<int>(this, f);
bool every(bool f(int element)) => Collections.every(this, f);
- bool some(bool f(int element)) => Collections.some(this, f);
+ bool any(bool f(int element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<int> take(int n) => new ListView<int>(this, 0, n);
+
+ Iterable<int> takeWhile(bool test(int value)) {
+ return new TakeWhileIterable<int>(this, test);
+ }
+
+ List<int> skip(int n) => new ListView<int>(this, n, null);
+
+ Iterable<int> skipWhile(bool test(int value)) {
+ return new SkipWhileIterable<int>(this, test);
+ }
+
+ int firstMatching(bool test(int value), { int orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ int lastMatching(bool test(int value), {int orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ int singleMatching(bool test(int value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ int elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<int>:
+
+ void add(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<int> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<int>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -11895,9 +12469,25 @@ class Int8Array extends ArrayBufferView implements JavaScriptIndexingBehavior, L
return Lists.lastIndexOf(this, element, start);
}
- int get first => this[0];
+ int get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ int get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -13538,27 +14128,13 @@ class NamedNodeMap implements JavaScriptIndexingBehavior, List<Node> native "*Na
// From Iterable<Node>:
- Iterator<Node> iterator() {
+ Iterator<Node> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Node>(this);
}
- // From Collection<Node>:
-
- void add(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Node> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -13567,17 +14143,60 @@ class NamedNodeMap implements JavaScriptIndexingBehavior, List<Node> native "*Na
void forEach(void f(Node element)) => Collections.forEach(this, f);
- Collection map(f(Node element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(Node element)) => new MappedList<Node, dynamic>(this, f);
- Collection<Node> filter(bool f(Node element)) =>
- Collections.filter(this, <Node>[], f);
+ Iterable<Node> where(bool f(Node element)) => new WhereIterable<Node>(this, f);
bool every(bool f(Node element)) => Collections.every(this, f);
- bool some(bool f(Node element)) => Collections.some(this, f);
+ bool any(bool f(Node element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Node> take(int n) => new ListView<Node>(this, 0, n);
+
+ Iterable<Node> takeWhile(bool test(Node value)) {
+ return new TakeWhileIterable<Node>(this, test);
+ }
+
+ List<Node> skip(int n) => new ListView<Node>(this, n, null);
+
+ Iterable<Node> skipWhile(bool test(Node value)) {
+ return new SkipWhileIterable<Node>(this, test);
+ }
+
+ Node firstMatching(bool test(Node value), { Node orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Node lastMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Node singleMatching(bool test(Node value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Node>:
+
+ void add(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Node> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Node>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -13599,9 +14218,25 @@ class NamedNodeMap implements JavaScriptIndexingBehavior, List<Node> native "*Na
return Lists.lastIndexOf(this, element, start);
}
- Node get first => this[0];
+ Node get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -13778,8 +14413,30 @@ class _ChildNodeListLazy implements List {
_ChildNodeListLazy(this._this);
- Node get first => JS('Node', '#.firstChild', _this);
- Node get last => JS('Node', '#.lastChild', _this);
+ Node get first {
+ Node result = JS('Node', '#.firstChild', _this);
+ if (result == null) throw new StateError("No elements");
+ return result;
+ }
+ Node get last {
+ Node result = JS('Node', '#.lastChild', _this);
+ 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 JS('Node', '#.firstChild', _this);
+ }
+
+ 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);
@@ -13790,8 +14447,8 @@ class _ChildNodeListLazy implements List {
}
- void addAll(Collection<Node> collection) {
- for (Node node in collection) {
+ void addAll(Iterable<Node> iterable) {
+ for (Node node in iterable) {
_this.$dom_appendChild(node);
}
}
@@ -13820,7 +14477,7 @@ class _ChildNodeListLazy implements List {
_this.$dom_replaceChild(value, this[index]);
}
- Iterator<Node> iterator() => _this.$dom_childNodes.iterator();
+ Iterator<Node> get iterator => _this.$dom_childNodes.iterator;
// TODO(jacobr): We can implement these methods much more efficiently by
// looking up the nodeList only once instead of once per iteration.
@@ -13833,19 +14490,56 @@ class _ChildNodeListLazy implements List {
return Collections.reduce(this, initialValue, combine);
}
- Collection map(f(Node element)) => Collections.map(this, [], f);
+ String join([String separator]) {
+ return Collections.joinList(this, separator);
+ }
+
+ List mappedBy(f(Node element)) =>
+ new MappedList<Node, dynamic>(this, f);
- Collection<Node> filter(bool f(Node element)) =>
- Collections.filter(this, <Node>[], f);
+ Iterable<Node> where(bool f(Node element)) =>
+ new WhereIterable<Node>(this, f);
bool every(bool f(Node element)) => Collections.every(this, f);
- bool some(bool f(Node element)) => Collections.some(this, f);
+ bool any(bool f(Node element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
// From List<Node>:
+ List<Node> take(int n) {
+ return new ListView<Node>(this, 0, n);
+ }
+
+ Iterable<Node> takeWhile(bool test(Node value)) {
+ return new TakeWhileIterable<Node>(this, test);
+ }
+
+ List<Node> skip(int n) {
+ return new ListView<Node>(this, n, null);
+ }
+
+ Iterable<Node> skipWhile(bool test(Node value)) {
+ return new SkipWhileIterable<Node>(this, test);
+ }
+
+ Node firstMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Node lastMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Node singleMatching(bool test(Node value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
// TODO(jacobr): this could be implemented for child node lists.
// The exception we throw here is misleading.
void sort([int compare(Node a, Node b)]) {
@@ -14156,27 +14850,13 @@ class NodeList implements JavaScriptIndexingBehavior, List<Node> native "*NodeLi
// From Iterable<Node>:
- Iterator<Node> iterator() {
+ Iterator<Node> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Node>(this);
}
- // From Collection<Node>:
-
- void add(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Node value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Node> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -14185,17 +14865,60 @@ class NodeList implements JavaScriptIndexingBehavior, List<Node> native "*NodeLi
void forEach(void f(Node element)) => Collections.forEach(this, f);
- Collection map(f(Node element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(Node element)) => new MappedList<Node, dynamic>(this, f);
- Collection<Node> filter(bool f(Node element)) =>
- Collections.filter(this, <Node>[], f);
+ Iterable<Node> where(bool f(Node element)) => new WhereIterable<Node>(this, f);
bool every(bool f(Node element)) => Collections.every(this, f);
- bool some(bool f(Node element)) => Collections.some(this, f);
+ bool any(bool f(Node element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Node> take(int n) => new ListView<Node>(this, 0, n);
+
+ Iterable<Node> takeWhile(bool test(Node value)) {
+ return new TakeWhileIterable<Node>(this, test);
+ }
+
+ List<Node> skip(int n) => new ListView<Node>(this, n, null);
+
+ Iterable<Node> skipWhile(bool test(Node value)) {
+ return new SkipWhileIterable<Node>(this, test);
+ }
+
+ Node firstMatching(bool test(Node value), { Node orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Node lastMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Node singleMatching(bool test(Node value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Node>:
+
+ void add(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Node value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Node> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Node>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -14217,9 +14940,25 @@ class NodeList implements JavaScriptIndexingBehavior, List<Node> native "*NodeLi
return Lists.lastIndexOf(this, element, start);
}
- Node get first => this[0];
+ Node get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ Node max([int compare(Node a, Node b)]) => _Collections.maxInList(this, compare);
Node removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -15808,13 +16547,13 @@ class SelectElement extends Element native "*HTMLSelectElement" {
// Override default options, since IE returns SelectElement itself and it
// does not operate as a List.
List<OptionElement> get options {
- return this.children.filter((e) => e is OptionElement);
+ return this.children.where((e) => e is OptionElement).toList();
}
List<OptionElement> get selectedOptions {
// IE does not change the selected flag for single-selection items.
if (this.multiple) {
- return this.options.filter((o) => o.selected);
+ return this.options.where((o) => o.selected).toList();
} else {
return [this.options[this.selectedIndex]];
}
@@ -15980,27 +16719,13 @@ class SourceBufferList extends EventTarget implements JavaScriptIndexingBehavior
// From Iterable<SourceBuffer>:
- Iterator<SourceBuffer> iterator() {
+ Iterator<SourceBuffer> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<SourceBuffer>(this);
}
- // From Collection<SourceBuffer>:
-
- void add(SourceBuffer value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(SourceBuffer value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<SourceBuffer> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SourceBuffer)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -16009,17 +16734,60 @@ class SourceBufferList extends EventTarget implements JavaScriptIndexingBehavior
void forEach(void f(SourceBuffer element)) => Collections.forEach(this, f);
- Collection map(f(SourceBuffer element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<SourceBuffer> filter(bool f(SourceBuffer element)) =>
- Collections.filter(this, <SourceBuffer>[], f);
+ List mappedBy(f(SourceBuffer element)) => new MappedList<SourceBuffer, dynamic>(this, f);
+
+ Iterable<SourceBuffer> where(bool f(SourceBuffer element)) => new WhereIterable<SourceBuffer>(this, f);
bool every(bool f(SourceBuffer element)) => Collections.every(this, f);
- bool some(bool f(SourceBuffer element)) => Collections.some(this, f);
+ bool any(bool f(SourceBuffer element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<SourceBuffer> take(int n) => new ListView<SourceBuffer>(this, 0, n);
+
+ Iterable<SourceBuffer> takeWhile(bool test(SourceBuffer value)) {
+ return new TakeWhileIterable<SourceBuffer>(this, test);
+ }
+
+ List<SourceBuffer> skip(int n) => new ListView<SourceBuffer>(this, n, null);
+
+ Iterable<SourceBuffer> skipWhile(bool test(SourceBuffer value)) {
+ return new SkipWhileIterable<SourceBuffer>(this, test);
+ }
+
+ SourceBuffer firstMatching(bool test(SourceBuffer value), { SourceBuffer orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ SourceBuffer lastMatching(bool test(SourceBuffer value), {SourceBuffer orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ SourceBuffer singleMatching(bool test(SourceBuffer value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ SourceBuffer elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<SourceBuffer>:
+
+ void add(SourceBuffer value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(SourceBuffer value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<SourceBuffer> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<SourceBuffer>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -16041,9 +16809,25 @@ class SourceBufferList extends EventTarget implements JavaScriptIndexingBehavior
return Lists.lastIndexOf(this, element, start);
}
- SourceBuffer get first => this[0];
+ SourceBuffer get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ SourceBuffer get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ SourceBuffer max([int compare(SourceBuffer a, SourceBuffer b)]) => _Collections.maxInList(this, compare);
SourceBuffer removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -16159,45 +16943,74 @@ class SpeechGrammarList implements JavaScriptIndexingBehavior, List<SpeechGramma
// From Iterable<SpeechGrammar>:
- Iterator<SpeechGrammar> iterator() {
+ Iterator<SpeechGrammar> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<SpeechGrammar>(this);
}
- // From Collection<SpeechGrammar>:
-
- void add(SpeechGrammar value) {
- throw new UnsupportedError("Cannot add to immutable List.");
+ dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
+ return Collections.reduce(this, initialValue, combine);
}
- void addLast(SpeechGrammar value) {
- throw new UnsupportedError("Cannot add to immutable List.");
+ bool contains(SpeechGrammar element) => Collections.contains(this, element);
+
+ void forEach(void f(SpeechGrammar element)) => Collections.forEach(this, f);
+
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(SpeechGrammar element)) => new MappedList<SpeechGrammar, dynamic>(this, f);
+
+ Iterable<SpeechGrammar> where(bool f(SpeechGrammar element)) => new WhereIterable<SpeechGrammar>(this, f);
+
+ bool every(bool f(SpeechGrammar element)) => Collections.every(this, f);
+
+ bool any(bool f(SpeechGrammar element)) => Collections.any(this, f);
+
+ bool get isEmpty => this.length == 0;
+
+ List<SpeechGrammar> take(int n) => new ListView<SpeechGrammar>(this, 0, n);
+
+ Iterable<SpeechGrammar> takeWhile(bool test(SpeechGrammar value)) {
+ return new TakeWhileIterable<SpeechGrammar>(this, test);
}
- void addAll(Collection<SpeechGrammar> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
+ List<SpeechGrammar> skip(int n) => new ListView<SpeechGrammar>(this, n, null);
+
+ Iterable<SpeechGrammar> skipWhile(bool test(SpeechGrammar value)) {
+ return new SkipWhileIterable<SpeechGrammar>(this, test);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
- return Collections.reduce(this, initialValue, combine);
+ SpeechGrammar firstMatching(bool test(SpeechGrammar value), { SpeechGrammar orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
}
- bool contains(SpeechGrammar element) => Collections.contains(this, element);
+ SpeechGrammar lastMatching(bool test(SpeechGrammar value), {SpeechGrammar orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
- void forEach(void f(SpeechGrammar element)) => Collections.forEach(this, f);
+ SpeechGrammar singleMatching(bool test(SpeechGrammar value)) {
+ return Collections.singleMatching(this, test);
+ }
- Collection map(f(SpeechGrammar element)) => Collections.map(this, [], f);
+ SpeechGrammar elementAt(int index) {
+ return this[index];
+ }
- Collection<SpeechGrammar> filter(bool f(SpeechGrammar element)) =>
- Collections.filter(this, <SpeechGrammar>[], f);
+ // From Collection<SpeechGrammar>:
- bool every(bool f(SpeechGrammar element)) => Collections.every(this, f);
+ void add(SpeechGrammar value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
- bool some(bool f(SpeechGrammar element)) => Collections.some(this, f);
+ void addLast(SpeechGrammar value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
- bool get isEmpty => this.length == 0;
+ void addAll(Iterable<SpeechGrammar> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
// From List<SpeechGrammar>:
void set length(int value) {
@@ -16220,9 +17033,25 @@ class SpeechGrammarList implements JavaScriptIndexingBehavior, List<SpeechGramma
return Lists.lastIndexOf(this, element, start);
}
- SpeechGrammar get first => this[0];
+ SpeechGrammar get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ SpeechGrammar get last {
+ if (this.length > 0) return this[this.length - 1];
+ throw new StateError("No elements");
+ }
- SpeechGrammar get last => this[length - 1];
+ 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.");
@@ -16540,27 +17369,13 @@ class SqlResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
// From Iterable<Map>:
- Iterator<Map> iterator() {
+ Iterator<Map> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Map>(this);
}
- // From Collection<Map>:
-
- void add(Map value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Map value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Map> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Map)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -16569,17 +17384,60 @@ class SqlResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
void forEach(void f(Map element)) => Collections.forEach(this, f);
- Collection map(f(Map element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(Map element)) => new MappedList<Map, dynamic>(this, f);
- Collection<Map> filter(bool f(Map element)) =>
- Collections.filter(this, <Map>[], f);
+ Iterable<Map> where(bool f(Map element)) => new WhereIterable<Map>(this, f);
bool every(bool f(Map element)) => Collections.every(this, f);
- bool some(bool f(Map element)) => Collections.some(this, f);
+ bool any(bool f(Map element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Map> take(int n) => new ListView<Map>(this, 0, n);
+
+ Iterable<Map> takeWhile(bool test(Map value)) {
+ return new TakeWhileIterable<Map>(this, test);
+ }
+
+ List<Map> skip(int n) => new ListView<Map>(this, n, null);
+
+ Iterable<Map> skipWhile(bool test(Map value)) {
+ return new SkipWhileIterable<Map>(this, test);
+ }
+
+ Map firstMatching(bool test(Map value), { Map orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Map lastMatching(bool test(Map value), {Map orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Map singleMatching(bool test(Map value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Map elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Map>:
+
+ void add(Map value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Map value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Map> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Map>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -16601,9 +17459,25 @@ class SqlResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
return Lists.lastIndexOf(this, element, start);
}
- Map get first => this[0];
+ Map get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ Map get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ Map max([int compare(Map a, Map b)]) => _Collections.maxInList(this, compare);
Map removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -16669,7 +17543,7 @@ class SqlTransactionSync native "*SQLTransactionSync" {
class Storage implements Map<String, String> native "*Storage" {
// TODO(nweiz): update this when maps support lazy iteration
- bool containsValue(String value) => values.some((e) => e == value);
+ bool containsValue(String value) => values.any((e) => e == value);
bool containsKey(String key) => $dom_getItem(key) != null;
@@ -17345,27 +18219,13 @@ class TextTrackCueList implements List<TextTrackCue>, JavaScriptIndexingBehavior
// From Iterable<TextTrackCue>:
- Iterator<TextTrackCue> iterator() {
+ Iterator<TextTrackCue> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<TextTrackCue>(this);
}
- // From Collection<TextTrackCue>:
-
- void add(TextTrackCue value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(TextTrackCue value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<TextTrackCue> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, TextTrackCue)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -17374,17 +18234,60 @@ class TextTrackCueList implements List<TextTrackCue>, JavaScriptIndexingBehavior
void forEach(void f(TextTrackCue element)) => Collections.forEach(this, f);
- Collection map(f(TextTrackCue element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(TextTrackCue element)) => new MappedList<TextTrackCue, dynamic>(this, f);
- Collection<TextTrackCue> filter(bool f(TextTrackCue element)) =>
- Collections.filter(this, <TextTrackCue>[], f);
+ Iterable<TextTrackCue> where(bool f(TextTrackCue element)) => new WhereIterable<TextTrackCue>(this, f);
bool every(bool f(TextTrackCue element)) => Collections.every(this, f);
- bool some(bool f(TextTrackCue element)) => Collections.some(this, f);
+ bool any(bool f(TextTrackCue element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<TextTrackCue> take(int n) => new ListView<TextTrackCue>(this, 0, n);
+
+ Iterable<TextTrackCue> takeWhile(bool test(TextTrackCue value)) {
+ return new TakeWhileIterable<TextTrackCue>(this, test);
+ }
+
+ List<TextTrackCue> skip(int n) => new ListView<TextTrackCue>(this, n, null);
+
+ Iterable<TextTrackCue> skipWhile(bool test(TextTrackCue value)) {
+ return new SkipWhileIterable<TextTrackCue>(this, test);
+ }
+
+ TextTrackCue firstMatching(bool test(TextTrackCue value), { TextTrackCue orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ TextTrackCue lastMatching(bool test(TextTrackCue value), {TextTrackCue orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ TextTrackCue singleMatching(bool test(TextTrackCue value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ TextTrackCue elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<TextTrackCue>:
+
+ void add(TextTrackCue value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(TextTrackCue value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<TextTrackCue> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<TextTrackCue>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -17406,9 +18309,25 @@ class TextTrackCueList implements List<TextTrackCue>, JavaScriptIndexingBehavior
return Lists.lastIndexOf(this, element, start);
}
- TextTrackCue get first => this[0];
+ TextTrackCue get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
- TextTrackCue get last => this[length - 1];
+ TextTrackCue get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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.");
@@ -17466,27 +18385,13 @@ class TextTrackList extends EventTarget implements JavaScriptIndexingBehavior, L
// From Iterable<TextTrack>:
- Iterator<TextTrack> iterator() {
+ Iterator<TextTrack> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<TextTrack>(this);
}
- // From Collection<TextTrack>:
-
- void add(TextTrack value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(TextTrack value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<TextTrack> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, TextTrack)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -17495,17 +18400,60 @@ class TextTrackList extends EventTarget implements JavaScriptIndexingBehavior, L
void forEach(void f(TextTrack element)) => Collections.forEach(this, f);
- Collection map(f(TextTrack element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(TextTrack element)) => new MappedList<TextTrack, dynamic>(this, f);
- Collection<TextTrack> filter(bool f(TextTrack element)) =>
- Collections.filter(this, <TextTrack>[], f);
+ Iterable<TextTrack> where(bool f(TextTrack element)) => new WhereIterable<TextTrack>(this, f);
bool every(bool f(TextTrack element)) => Collections.every(this, f);
- bool some(bool f(TextTrack element)) => Collections.some(this, f);
+ bool any(bool f(TextTrack element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<TextTrack> take(int n) => new ListView<TextTrack>(this, 0, n);
+
+ Iterable<TextTrack> takeWhile(bool test(TextTrack value)) {
+ return new TakeWhileIterable<TextTrack>(this, test);
+ }
+
+ List<TextTrack> skip(int n) => new ListView<TextTrack>(this, n, null);
+
+ Iterable<TextTrack> skipWhile(bool test(TextTrack value)) {
+ return new SkipWhileIterable<TextTrack>(this, test);
+ }
+
+ TextTrack firstMatching(bool test(TextTrack value), { TextTrack orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ TextTrack lastMatching(bool test(TextTrack value), {TextTrack orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ TextTrack singleMatching(bool test(TextTrack value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ TextTrack elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<TextTrack>:
+
+ void add(TextTrack value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(TextTrack value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<TextTrack> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<TextTrack>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -17527,9 +18475,25 @@ class TextTrackList extends EventTarget implements JavaScriptIndexingBehavior, L
return Lists.lastIndexOf(this, element, start);
}
- TextTrack get first => this[0];
+ TextTrack get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ TextTrack get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ 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.");
@@ -17716,27 +18680,13 @@ class TouchList implements JavaScriptIndexingBehavior, List<Touch> native "*Touc
// From Iterable<Touch>:
- Iterator<Touch> iterator() {
+ Iterator<Touch> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Touch>(this);
}
- // From Collection<Touch>:
-
- void add(Touch value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Touch value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Touch> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Touch)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -17745,17 +18695,60 @@ class TouchList implements JavaScriptIndexingBehavior, List<Touch> native "*Touc
void forEach(void f(Touch element)) => Collections.forEach(this, f);
- Collection map(f(Touch element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<Touch> filter(bool f(Touch element)) =>
- Collections.filter(this, <Touch>[], f);
+ List mappedBy(f(Touch element)) => new MappedList<Touch, dynamic>(this, f);
+
+ Iterable<Touch> where(bool f(Touch element)) => new WhereIterable<Touch>(this, f);
bool every(bool f(Touch element)) => Collections.every(this, f);
- bool some(bool f(Touch element)) => Collections.some(this, f);
+ bool any(bool f(Touch element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Touch> take(int n) => new ListView<Touch>(this, 0, n);
+
+ Iterable<Touch> takeWhile(bool test(Touch value)) {
+ return new TakeWhileIterable<Touch>(this, test);
+ }
+
+ List<Touch> skip(int n) => new ListView<Touch>(this, n, null);
+
+ Iterable<Touch> skipWhile(bool test(Touch value)) {
+ return new SkipWhileIterable<Touch>(this, test);
+ }
+
+ Touch firstMatching(bool test(Touch value), { Touch orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Touch lastMatching(bool test(Touch value), {Touch orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Touch singleMatching(bool test(Touch value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Touch elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Touch>:
+
+ void add(Touch value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Touch value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Touch> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Touch>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -17777,9 +18770,25 @@ class TouchList implements JavaScriptIndexingBehavior, List<Touch> native "*Touc
return Lists.lastIndexOf(this, element, start);
}
- Touch get first => this[0];
+ Touch get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
- Touch get last => this[length - 1];
+ Touch get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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.");
@@ -18026,27 +19035,13 @@ class Uint16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
// From Iterable<int>:
- Iterator<int> iterator() {
+ Iterator<int> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<int>(this);
}
- // From Collection<int>:
-
- void add(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<int> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -18055,17 +19050,60 @@ class Uint16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => Collections.forEach(this, f);
- Collection map(f(int element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(int element)) => new MappedList<int, dynamic>(this, f);
- Collection<int> filter(bool f(int element)) =>
- Collections.filter(this, <int>[], f);
+ Iterable<int> where(bool f(int element)) => new WhereIterable<int>(this, f);
bool every(bool f(int element)) => Collections.every(this, f);
- bool some(bool f(int element)) => Collections.some(this, f);
+ bool any(bool f(int element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<int> take(int n) => new ListView<int>(this, 0, n);
+
+ Iterable<int> takeWhile(bool test(int value)) {
+ return new TakeWhileIterable<int>(this, test);
+ }
+
+ List<int> skip(int n) => new ListView<int>(this, n, null);
+
+ Iterable<int> skipWhile(bool test(int value)) {
+ return new SkipWhileIterable<int>(this, test);
+ }
+
+ int firstMatching(bool test(int value), { int orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ int lastMatching(bool test(int value), {int orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ int singleMatching(bool test(int value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ int elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<int>:
+
+ void add(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<int> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<int>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -18087,9 +19125,25 @@ class Uint16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
return Lists.lastIndexOf(this, element, start);
}
- int get first => this[0];
+ int get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ int get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -18152,27 +19206,13 @@ class Uint32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
// From Iterable<int>:
- Iterator<int> iterator() {
+ Iterator<int> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<int>(this);
}
- // From Collection<int>:
-
- void add(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<int> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -18181,17 +19221,60 @@ class Uint32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => Collections.forEach(this, f);
- Collection map(f(int element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(int element)) => new MappedList<int, dynamic>(this, f);
- Collection<int> filter(bool f(int element)) =>
- Collections.filter(this, <int>[], f);
+ Iterable<int> where(bool f(int element)) => new WhereIterable<int>(this, f);
bool every(bool f(int element)) => Collections.every(this, f);
- bool some(bool f(int element)) => Collections.some(this, f);
+ bool any(bool f(int element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<int> take(int n) => new ListView<int>(this, 0, n);
+
+ Iterable<int> takeWhile(bool test(int value)) {
+ return new TakeWhileIterable<int>(this, test);
+ }
+
+ List<int> skip(int n) => new ListView<int>(this, n, null);
+
+ Iterable<int> skipWhile(bool test(int value)) {
+ return new SkipWhileIterable<int>(this, test);
+ }
+
+ int firstMatching(bool test(int value), { int orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ int lastMatching(bool test(int value), {int orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ int singleMatching(bool test(int value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ int elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<int>:
+
+ void add(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<int> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<int>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -18213,9 +19296,25 @@ class Uint32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
return Lists.lastIndexOf(this, element, start);
}
- int get first => this[0];
+ int get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ int get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -18278,45 +19377,74 @@ class Uint8Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
// From Iterable<int>:
- Iterator<int> iterator() {
+ Iterator<int> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<int>(this);
}
- // From Collection<int>:
-
- void add(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
+ dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
+ return Collections.reduce(this, initialValue, combine);
}
- void addLast(int value) {
- throw new UnsupportedError("Cannot add to immutable List.");
+ bool contains(int element) => Collections.contains(this, element);
+
+ void forEach(void f(int element)) => Collections.forEach(this, f);
+
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(int element)) => new MappedList<int, dynamic>(this, f);
+
+ Iterable<int> where(bool f(int element)) => new WhereIterable<int>(this, f);
+
+ bool every(bool f(int element)) => Collections.every(this, f);
+
+ bool any(bool f(int element)) => Collections.any(this, f);
+
+ bool get isEmpty => this.length == 0;
+
+ List<int> take(int n) => new ListView<int>(this, 0, n);
+
+ Iterable<int> takeWhile(bool test(int value)) {
+ return new TakeWhileIterable<int>(this, test);
}
- void addAll(Collection<int> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
+ List<int> skip(int n) => new ListView<int>(this, n, null);
+
+ Iterable<int> skipWhile(bool test(int value)) {
+ return new SkipWhileIterable<int>(this, test);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return Collections.reduce(this, initialValue, combine);
+ int firstMatching(bool test(int value), { int orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
}
- bool contains(int element) => Collections.contains(this, element);
+ int lastMatching(bool test(int value), {int orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
- void forEach(void f(int element)) => Collections.forEach(this, f);
+ int singleMatching(bool test(int value)) {
+ return Collections.singleMatching(this, test);
+ }
- Collection map(f(int element)) => Collections.map(this, [], f);
+ int elementAt(int index) {
+ return this[index];
+ }
- Collection<int> filter(bool f(int element)) =>
- Collections.filter(this, <int>[], f);
+ // From Collection<int>:
- bool every(bool f(int element)) => Collections.every(this, f);
+ void add(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
- bool some(bool f(int element)) => Collections.some(this, f);
+ void addLast(int value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
- bool get isEmpty => this.length == 0;
+ void addAll(Iterable<int> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
// From List<int>:
void set length(int value) {
@@ -18339,9 +19467,25 @@ class Uint8Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
return Lists.lastIndexOf(this, element, start);
}
- int get first => this[0];
+ int get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ int get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ int max([int compare(int a, int b)]) => _Collections.maxInList(this, compare);
int removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -20221,7 +21365,7 @@ class Window extends EventTarget implements WindowBase native "@*DOMWindow" {
* registered under [name].
*/
SendPortSync lookupPort(String name) {
- var port = JSON.parse(document.documentElement.attributes['dart-port:$name']);
+ var port = json.parse(document.documentElement.attributes['dart-port:$name']);
return _deserialize(port);
}
@@ -20232,7 +21376,7 @@ class Window extends EventTarget implements WindowBase native "@*DOMWindow" {
*/
void registerPort(String name, var port) {
var serialized = _serialize(port);
- document.documentElement.attributes['dart-port:$name'] = JSON.stringify(serialized);
+ document.documentElement.attributes['dart-port:$name'] = json.stringify(serialized);
}
/// @domName Window.console; @docsEditable true
@@ -21150,27 +22294,13 @@ class _ClientRectList implements JavaScriptIndexingBehavior, List<ClientRect> na
// From Iterable<ClientRect>:
- Iterator<ClientRect> iterator() {
+ Iterator<ClientRect> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<ClientRect>(this);
}
- // From Collection<ClientRect>:
-
- void add(ClientRect value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(ClientRect value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<ClientRect> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, ClientRect)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21179,17 +22309,60 @@ class _ClientRectList implements JavaScriptIndexingBehavior, List<ClientRect> na
void forEach(void f(ClientRect element)) => Collections.forEach(this, f);
- Collection map(f(ClientRect element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(ClientRect element)) => new MappedList<ClientRect, dynamic>(this, f);
- Collection<ClientRect> filter(bool f(ClientRect element)) =>
- Collections.filter(this, <ClientRect>[], f);
+ Iterable<ClientRect> where(bool f(ClientRect element)) => new WhereIterable<ClientRect>(this, f);
bool every(bool f(ClientRect element)) => Collections.every(this, f);
- bool some(bool f(ClientRect element)) => Collections.some(this, f);
+ bool any(bool f(ClientRect element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<ClientRect> take(int n) => new ListView<ClientRect>(this, 0, n);
+
+ Iterable<ClientRect> takeWhile(bool test(ClientRect value)) {
+ return new TakeWhileIterable<ClientRect>(this, test);
+ }
+
+ List<ClientRect> skip(int n) => new ListView<ClientRect>(this, n, null);
+
+ Iterable<ClientRect> skipWhile(bool test(ClientRect value)) {
+ return new SkipWhileIterable<ClientRect>(this, test);
+ }
+
+ ClientRect firstMatching(bool test(ClientRect value), { ClientRect orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ ClientRect lastMatching(bool test(ClientRect value), {ClientRect orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ ClientRect singleMatching(bool test(ClientRect value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ ClientRect elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<ClientRect>:
+
+ void add(ClientRect value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(ClientRect value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<ClientRect> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<ClientRect>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -21211,9 +22384,25 @@ class _ClientRectList implements JavaScriptIndexingBehavior, List<ClientRect> na
return Lists.lastIndexOf(this, element, start);
}
- ClientRect get first => this[0];
+ ClientRect get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ ClientRect get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ ClientRect max([int compare(ClientRect a, ClientRect b)]) => _Collections.maxInList(this, compare);
ClientRect removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -21264,27 +22453,13 @@ class _CssRuleList implements JavaScriptIndexingBehavior, List<CssRule> native "
// From Iterable<CssRule>:
- Iterator<CssRule> iterator() {
+ Iterator<CssRule> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<CssRule>(this);
}
- // From Collection<CssRule>:
-
- void add(CssRule value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(CssRule value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<CssRule> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, CssRule)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21293,17 +22468,60 @@ class _CssRuleList implements JavaScriptIndexingBehavior, List<CssRule> native "
void forEach(void f(CssRule element)) => Collections.forEach(this, f);
- Collection map(f(CssRule element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<CssRule> filter(bool f(CssRule element)) =>
- Collections.filter(this, <CssRule>[], f);
+ List mappedBy(f(CssRule element)) => new MappedList<CssRule, dynamic>(this, f);
+
+ Iterable<CssRule> where(bool f(CssRule element)) => new WhereIterable<CssRule>(this, f);
bool every(bool f(CssRule element)) => Collections.every(this, f);
- bool some(bool f(CssRule element)) => Collections.some(this, f);
+ bool any(bool f(CssRule element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<CssRule> take(int n) => new ListView<CssRule>(this, 0, n);
+
+ Iterable<CssRule> takeWhile(bool test(CssRule value)) {
+ return new TakeWhileIterable<CssRule>(this, test);
+ }
+
+ List<CssRule> skip(int n) => new ListView<CssRule>(this, n, null);
+
+ Iterable<CssRule> skipWhile(bool test(CssRule value)) {
+ return new SkipWhileIterable<CssRule>(this, test);
+ }
+
+ CssRule firstMatching(bool test(CssRule value), { CssRule orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ CssRule lastMatching(bool test(CssRule value), {CssRule orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ CssRule singleMatching(bool test(CssRule value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ CssRule elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<CssRule>:
+
+ void add(CssRule value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(CssRule value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<CssRule> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<CssRule>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -21325,9 +22543,25 @@ class _CssRuleList implements JavaScriptIndexingBehavior, List<CssRule> native "
return Lists.lastIndexOf(this, element, start);
}
- CssRule get first => this[0];
+ CssRule get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ CssRule get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ CssRule max([int compare(CssRule a, CssRule b)]) => _Collections.maxInList(this, compare);
CssRule removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -21378,27 +22612,13 @@ class _CssValueList extends CssValue implements List<CssValue>, JavaScriptIndexi
// From Iterable<CssValue>:
- Iterator<CssValue> iterator() {
+ Iterator<CssValue> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<CssValue>(this);
}
- // From Collection<CssValue>:
-
- void add(CssValue value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(CssValue value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<CssValue> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, CssValue)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21407,17 +22627,60 @@ class _CssValueList extends CssValue implements List<CssValue>, JavaScriptIndexi
void forEach(void f(CssValue element)) => Collections.forEach(this, f);
- Collection map(f(CssValue element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(CssValue element)) => new MappedList<CssValue, dynamic>(this, f);
- Collection<CssValue> filter(bool f(CssValue element)) =>
- Collections.filter(this, <CssValue>[], f);
+ Iterable<CssValue> where(bool f(CssValue element)) => new WhereIterable<CssValue>(this, f);
bool every(bool f(CssValue element)) => Collections.every(this, f);
- bool some(bool f(CssValue element)) => Collections.some(this, f);
+ bool any(bool f(CssValue element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<CssValue> take(int n) => new ListView<CssValue>(this, 0, n);
+
+ Iterable<CssValue> takeWhile(bool test(CssValue value)) {
+ return new TakeWhileIterable<CssValue>(this, test);
+ }
+
+ List<CssValue> skip(int n) => new ListView<CssValue>(this, n, null);
+
+ Iterable<CssValue> skipWhile(bool test(CssValue value)) {
+ return new SkipWhileIterable<CssValue>(this, test);
+ }
+
+ CssValue firstMatching(bool test(CssValue value), { CssValue orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ CssValue lastMatching(bool test(CssValue value), {CssValue orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ CssValue singleMatching(bool test(CssValue value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ CssValue elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<CssValue>:
+
+ void add(CssValue value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(CssValue value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<CssValue> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<CssValue>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -21439,9 +22702,25 @@ class _CssValueList extends CssValue implements List<CssValue>, JavaScriptIndexi
return Lists.lastIndexOf(this, element, start);
}
- CssValue get first => this[0];
+ CssValue get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ CssValue get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ CssValue max([int compare(CssValue a, CssValue b)]) => _Collections.maxInList(this, compare);
CssValue removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -21492,27 +22771,13 @@ class _EntryArray implements JavaScriptIndexingBehavior, List<Entry> native "*En
// From Iterable<Entry>:
- Iterator<Entry> iterator() {
+ Iterator<Entry> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Entry>(this);
}
- // From Collection<Entry>:
-
- void add(Entry value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Entry value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Entry> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Entry)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21521,17 +22786,60 @@ class _EntryArray implements JavaScriptIndexingBehavior, List<Entry> native "*En
void forEach(void f(Entry element)) => Collections.forEach(this, f);
- Collection map(f(Entry element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<Entry> filter(bool f(Entry element)) =>
- Collections.filter(this, <Entry>[], f);
+ List mappedBy(f(Entry element)) => new MappedList<Entry, dynamic>(this, f);
+
+ Iterable<Entry> where(bool f(Entry element)) => new WhereIterable<Entry>(this, f);
bool every(bool f(Entry element)) => Collections.every(this, f);
- bool some(bool f(Entry element)) => Collections.some(this, f);
+ bool any(bool f(Entry element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Entry> take(int n) => new ListView<Entry>(this, 0, n);
+
+ Iterable<Entry> takeWhile(bool test(Entry value)) {
+ return new TakeWhileIterable<Entry>(this, test);
+ }
+
+ List<Entry> skip(int n) => new ListView<Entry>(this, n, null);
+
+ Iterable<Entry> skipWhile(bool test(Entry value)) {
+ return new SkipWhileIterable<Entry>(this, test);
+ }
+
+ Entry firstMatching(bool test(Entry value), { Entry orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Entry lastMatching(bool test(Entry value), {Entry orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Entry singleMatching(bool test(Entry value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Entry elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Entry>:
+
+ void add(Entry value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Entry value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Entry> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Entry>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -21553,9 +22861,25 @@ class _EntryArray implements JavaScriptIndexingBehavior, List<Entry> native "*En
return Lists.lastIndexOf(this, element, start);
}
- Entry get first => this[0];
+ Entry get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ Entry get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ Entry max([int compare(Entry a, Entry b)]) => _Collections.maxInList(this, compare);
Entry removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -21606,27 +22930,13 @@ class _EntryArraySync implements JavaScriptIndexingBehavior, List<EntrySync> nat
// From Iterable<EntrySync>:
- Iterator<EntrySync> iterator() {
+ Iterator<EntrySync> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<EntrySync>(this);
}
- // From Collection<EntrySync>:
-
- void add(EntrySync value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(EntrySync value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<EntrySync> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, EntrySync)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21635,17 +22945,60 @@ class _EntryArraySync implements JavaScriptIndexingBehavior, List<EntrySync> nat
void forEach(void f(EntrySync element)) => Collections.forEach(this, f);
- Collection map(f(EntrySync element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(EntrySync element)) => new MappedList<EntrySync, dynamic>(this, f);
- Collection<EntrySync> filter(bool f(EntrySync element)) =>
- Collections.filter(this, <EntrySync>[], f);
+ Iterable<EntrySync> where(bool f(EntrySync element)) => new WhereIterable<EntrySync>(this, f);
bool every(bool f(EntrySync element)) => Collections.every(this, f);
- bool some(bool f(EntrySync element)) => Collections.some(this, f);
+ bool any(bool f(EntrySync element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<EntrySync> take(int n) => new ListView<EntrySync>(this, 0, n);
+
+ Iterable<EntrySync> takeWhile(bool test(EntrySync value)) {
+ return new TakeWhileIterable<EntrySync>(this, test);
+ }
+
+ List<EntrySync> skip(int n) => new ListView<EntrySync>(this, n, null);
+
+ Iterable<EntrySync> skipWhile(bool test(EntrySync value)) {
+ return new SkipWhileIterable<EntrySync>(this, test);
+ }
+
+ EntrySync firstMatching(bool test(EntrySync value), { EntrySync orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ EntrySync lastMatching(bool test(EntrySync value), {EntrySync orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ EntrySync singleMatching(bool test(EntrySync value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ EntrySync elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<EntrySync>:
+
+ void add(EntrySync value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(EntrySync value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<EntrySync> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<EntrySync>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -21662,14 +23015,30 @@ class _EntryArraySync implements JavaScriptIndexingBehavior, List<EntrySync> nat
int indexOf(EntrySync element, [int start = 0]) =>
Lists.indexOf(this, element, start, this.length);
- int lastIndexOf(EntrySync element, [int start]) {
- if (start == null) start = length - 1;
- return Lists.lastIndexOf(this, element, start);
+ int lastIndexOf(EntrySync element, [int start]) {
+ if (start == null) start = length - 1;
+ return Lists.lastIndexOf(this, element, start);
+ }
+
+ EntrySync get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ EntrySync get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get first => this[0];
+ EntrySync min([int compare(EntrySync a, EntrySync b)]) => _Collections.minInList(this, compare);
- EntrySync get last => this[length - 1];
+ EntrySync max([int compare(EntrySync a, EntrySync b)]) => _Collections.maxInList(this, compare);
EntrySync removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -21720,27 +23089,13 @@ class _GamepadList implements JavaScriptIndexingBehavior, List<Gamepad> native "
// From Iterable<Gamepad>:
- Iterator<Gamepad> iterator() {
+ Iterator<Gamepad> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<Gamepad>(this);
}
- // From Collection<Gamepad>:
-
- void add(Gamepad value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(Gamepad value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<Gamepad> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Gamepad)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21749,17 +23104,60 @@ class _GamepadList implements JavaScriptIndexingBehavior, List<Gamepad> native "
void forEach(void f(Gamepad element)) => Collections.forEach(this, f);
- Collection map(f(Gamepad element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<Gamepad> filter(bool f(Gamepad element)) =>
- Collections.filter(this, <Gamepad>[], f);
+ List mappedBy(f(Gamepad element)) => new MappedList<Gamepad, dynamic>(this, f);
+
+ Iterable<Gamepad> where(bool f(Gamepad element)) => new WhereIterable<Gamepad>(this, f);
bool every(bool f(Gamepad element)) => Collections.every(this, f);
- bool some(bool f(Gamepad element)) => Collections.some(this, f);
+ bool any(bool f(Gamepad element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<Gamepad> take(int n) => new ListView<Gamepad>(this, 0, n);
+
+ Iterable<Gamepad> takeWhile(bool test(Gamepad value)) {
+ return new TakeWhileIterable<Gamepad>(this, test);
+ }
+
+ List<Gamepad> skip(int n) => new ListView<Gamepad>(this, n, null);
+
+ Iterable<Gamepad> skipWhile(bool test(Gamepad value)) {
+ return new SkipWhileIterable<Gamepad>(this, test);
+ }
+
+ Gamepad firstMatching(bool test(Gamepad value), { Gamepad orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Gamepad lastMatching(bool test(Gamepad value), {Gamepad orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ Gamepad singleMatching(bool test(Gamepad value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Gamepad elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<Gamepad>:
+
+ void add(Gamepad value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(Gamepad value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<Gamepad> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<Gamepad>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -21781,9 +23179,25 @@ class _GamepadList implements JavaScriptIndexingBehavior, List<Gamepad> native "
return Lists.lastIndexOf(this, element, start);
}
- Gamepad get first => this[0];
+ Gamepad get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ Gamepad get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ Gamepad max([int compare(Gamepad a, Gamepad b)]) => _Collections.maxInList(this, compare);
Gamepad removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -21834,27 +23248,13 @@ class _MediaStreamList implements JavaScriptIndexingBehavior, List<MediaStream>
// From Iterable<MediaStream>:
- Iterator<MediaStream> iterator() {
+ Iterator<MediaStream> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<MediaStream>(this);
}
- // From Collection<MediaStream>:
-
- void add(MediaStream value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(MediaStream value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<MediaStream> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, MediaStream)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21863,17 +23263,60 @@ class _MediaStreamList implements JavaScriptIndexingBehavior, List<MediaStream>
void forEach(void f(MediaStream element)) => Collections.forEach(this, f);
- Collection map(f(MediaStream element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(MediaStream element)) => new MappedList<MediaStream, dynamic>(this, f);
- Collection<MediaStream> filter(bool f(MediaStream element)) =>
- Collections.filter(this, <MediaStream>[], f);
+ Iterable<MediaStream> where(bool f(MediaStream element)) => new WhereIterable<MediaStream>(this, f);
bool every(bool f(MediaStream element)) => Collections.every(this, f);
- bool some(bool f(MediaStream element)) => Collections.some(this, f);
+ bool any(bool f(MediaStream element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<MediaStream> take(int n) => new ListView<MediaStream>(this, 0, n);
+
+ Iterable<MediaStream> takeWhile(bool test(MediaStream value)) {
+ return new TakeWhileIterable<MediaStream>(this, test);
+ }
+
+ List<MediaStream> skip(int n) => new ListView<MediaStream>(this, n, null);
+
+ Iterable<MediaStream> skipWhile(bool test(MediaStream value)) {
+ return new SkipWhileIterable<MediaStream>(this, test);
+ }
+
+ MediaStream firstMatching(bool test(MediaStream value), { MediaStream orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ MediaStream lastMatching(bool test(MediaStream value), {MediaStream orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ MediaStream singleMatching(bool test(MediaStream value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ MediaStream elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<MediaStream>:
+
+ void add(MediaStream value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(MediaStream value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<MediaStream> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<MediaStream>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -21895,9 +23338,25 @@ class _MediaStreamList implements JavaScriptIndexingBehavior, List<MediaStream>
return Lists.lastIndexOf(this, element, start);
}
- MediaStream get first => this[0];
+ MediaStream get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ MediaStream get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ MediaStream max([int compare(MediaStream a, MediaStream b)]) => _Collections.maxInList(this, compare);
MediaStream removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -21948,27 +23407,13 @@ class _SpeechInputResultList implements JavaScriptIndexingBehavior, List<SpeechI
// From Iterable<SpeechInputResult>:
- Iterator<SpeechInputResult> iterator() {
+ Iterator<SpeechInputResult> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<SpeechInputResult>(this);
}
- // From Collection<SpeechInputResult>:
-
- void add(SpeechInputResult value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(SpeechInputResult value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<SpeechInputResult> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechInputResult)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -21977,17 +23422,60 @@ class _SpeechInputResultList implements JavaScriptIndexingBehavior, List<SpeechI
void forEach(void f(SpeechInputResult element)) => Collections.forEach(this, f);
- Collection map(f(SpeechInputResult element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<SpeechInputResult> filter(bool f(SpeechInputResult element)) =>
- Collections.filter(this, <SpeechInputResult>[], f);
+ List mappedBy(f(SpeechInputResult element)) => new MappedList<SpeechInputResult, dynamic>(this, f);
+
+ Iterable<SpeechInputResult> where(bool f(SpeechInputResult element)) => new WhereIterable<SpeechInputResult>(this, f);
bool every(bool f(SpeechInputResult element)) => Collections.every(this, f);
- bool some(bool f(SpeechInputResult element)) => Collections.some(this, f);
+ bool any(bool f(SpeechInputResult element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<SpeechInputResult> take(int n) => new ListView<SpeechInputResult>(this, 0, n);
+
+ Iterable<SpeechInputResult> takeWhile(bool test(SpeechInputResult value)) {
+ return new TakeWhileIterable<SpeechInputResult>(this, test);
+ }
+
+ List<SpeechInputResult> skip(int n) => new ListView<SpeechInputResult>(this, n, null);
+
+ Iterable<SpeechInputResult> skipWhile(bool test(SpeechInputResult value)) {
+ return new SkipWhileIterable<SpeechInputResult>(this, test);
+ }
+
+ SpeechInputResult firstMatching(bool test(SpeechInputResult value), { SpeechInputResult orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ SpeechInputResult lastMatching(bool test(SpeechInputResult value), {SpeechInputResult orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ SpeechInputResult singleMatching(bool test(SpeechInputResult value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ SpeechInputResult elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<SpeechInputResult>:
+
+ void add(SpeechInputResult value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(SpeechInputResult value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<SpeechInputResult> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<SpeechInputResult>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -22009,9 +23497,25 @@ class _SpeechInputResultList implements JavaScriptIndexingBehavior, List<SpeechI
return Lists.lastIndexOf(this, element, start);
}
- SpeechInputResult get first => this[0];
+ SpeechInputResult get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ SpeechInputResult get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ SpeechInputResult max([int compare(SpeechInputResult a, SpeechInputResult b)]) => _Collections.maxInList(this, compare);
SpeechInputResult removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -22062,27 +23566,13 @@ class _SpeechRecognitionResultList implements JavaScriptIndexingBehavior, List<S
// From Iterable<SpeechRecognitionResult>:
- Iterator<SpeechRecognitionResult> iterator() {
+ Iterator<SpeechRecognitionResult> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<SpeechRecognitionResult>(this);
}
- // From Collection<SpeechRecognitionResult>:
-
- void add(SpeechRecognitionResult value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(SpeechRecognitionResult value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<SpeechRecognitionResult> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechRecognitionResult)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -22091,17 +23581,60 @@ class _SpeechRecognitionResultList implements JavaScriptIndexingBehavior, List<S
void forEach(void f(SpeechRecognitionResult element)) => Collections.forEach(this, f);
- Collection map(f(SpeechRecognitionResult element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
+
+ List mappedBy(f(SpeechRecognitionResult element)) => new MappedList<SpeechRecognitionResult, dynamic>(this, f);
- Collection<SpeechRecognitionResult> filter(bool f(SpeechRecognitionResult element)) =>
- Collections.filter(this, <SpeechRecognitionResult>[], f);
+ Iterable<SpeechRecognitionResult> where(bool f(SpeechRecognitionResult element)) => new WhereIterable<SpeechRecognitionResult>(this, f);
bool every(bool f(SpeechRecognitionResult element)) => Collections.every(this, f);
- bool some(bool f(SpeechRecognitionResult element)) => Collections.some(this, f);
+ bool any(bool f(SpeechRecognitionResult element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<SpeechRecognitionResult> take(int n) => new ListView<SpeechRecognitionResult>(this, 0, n);
+
+ Iterable<SpeechRecognitionResult> takeWhile(bool test(SpeechRecognitionResult value)) {
+ return new TakeWhileIterable<SpeechRecognitionResult>(this, test);
+ }
+
+ List<SpeechRecognitionResult> skip(int n) => new ListView<SpeechRecognitionResult>(this, n, null);
+
+ Iterable<SpeechRecognitionResult> skipWhile(bool test(SpeechRecognitionResult value)) {
+ return new SkipWhileIterable<SpeechRecognitionResult>(this, test);
+ }
+
+ SpeechRecognitionResult firstMatching(bool test(SpeechRecognitionResult value), { SpeechRecognitionResult orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ SpeechRecognitionResult lastMatching(bool test(SpeechRecognitionResult value), {SpeechRecognitionResult orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ SpeechRecognitionResult singleMatching(bool test(SpeechRecognitionResult value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ SpeechRecognitionResult elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<SpeechRecognitionResult>:
+
+ void add(SpeechRecognitionResult value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(SpeechRecognitionResult value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<SpeechRecognitionResult> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<SpeechRecognitionResult>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -22123,9 +23656,25 @@ class _SpeechRecognitionResultList implements JavaScriptIndexingBehavior, List<S
return Lists.lastIndexOf(this, element, start);
}
- SpeechRecognitionResult get first => this[0];
+ SpeechRecognitionResult get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ SpeechRecognitionResult get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ SpeechRecognitionResult max([int compare(SpeechRecognitionResult a, SpeechRecognitionResult b)]) => _Collections.maxInList(this, compare);
SpeechRecognitionResult removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -22176,27 +23725,13 @@ class _StyleSheetList implements JavaScriptIndexingBehavior, List<StyleSheet> na
// From Iterable<StyleSheet>:
- Iterator<StyleSheet> iterator() {
+ Iterator<StyleSheet> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
return new FixedSizeListIterator<StyleSheet>(this);
}
- // From Collection<StyleSheet>:
-
- void add(StyleSheet value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addLast(StyleSheet value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Collection<StyleSheet> collection) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
dynamic reduce(dynamic initialValue, dynamic combine(dynamic, StyleSheet)) {
return Collections.reduce(this, initialValue, combine);
}
@@ -22205,17 +23740,60 @@ class _StyleSheetList implements JavaScriptIndexingBehavior, List<StyleSheet> na
void forEach(void f(StyleSheet element)) => Collections.forEach(this, f);
- Collection map(f(StyleSheet element)) => Collections.map(this, [], f);
+ String join([String separator]) => Collections.joinList(this, separator);
- Collection<StyleSheet> filter(bool f(StyleSheet element)) =>
- Collections.filter(this, <StyleSheet>[], f);
+ List mappedBy(f(StyleSheet element)) => new MappedList<StyleSheet, dynamic>(this, f);
+
+ Iterable<StyleSheet> where(bool f(StyleSheet element)) => new WhereIterable<StyleSheet>(this, f);
bool every(bool f(StyleSheet element)) => Collections.every(this, f);
- bool some(bool f(StyleSheet element)) => Collections.some(this, f);
+ bool any(bool f(StyleSheet element)) => Collections.any(this, f);
bool get isEmpty => this.length == 0;
+ List<StyleSheet> take(int n) => new ListView<StyleSheet>(this, 0, n);
+
+ Iterable<StyleSheet> takeWhile(bool test(StyleSheet value)) {
+ return new TakeWhileIterable<StyleSheet>(this, test);
+ }
+
+ List<StyleSheet> skip(int n) => new ListView<StyleSheet>(this, n, null);
+
+ Iterable<StyleSheet> skipWhile(bool test(StyleSheet value)) {
+ return new SkipWhileIterable<StyleSheet>(this, test);
+ }
+
+ StyleSheet firstMatching(bool test(StyleSheet value), { StyleSheet orElse() }) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ StyleSheet lastMatching(bool test(StyleSheet value), {StyleSheet orElse()}) {
+ return Collections.lastMatchingInList(this, test, orElse);
+ }
+
+ StyleSheet singleMatching(bool test(StyleSheet value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ StyleSheet elementAt(int index) {
+ return this[index];
+ }
+
+ // From Collection<StyleSheet>:
+
+ void add(StyleSheet value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addLast(StyleSheet value) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
+ void addAll(Iterable<StyleSheet> iterable) {
+ throw new UnsupportedError("Cannot add to immutable List.");
+ }
+
// From List<StyleSheet>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
@@ -22237,9 +23815,25 @@ class _StyleSheetList implements JavaScriptIndexingBehavior, List<StyleSheet> na
return Lists.lastIndexOf(this, element, start);
}
- StyleSheet get first => this[0];
+ StyleSheet get first {
+ if (this.length > 0) return this[0];
+ throw new StateError("No elements");
+ }
+
+ StyleSheet get last {
+ if (this.length > 0) return this[this.length - 1];
+ 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 get last => this[length - 1];
+ StyleSheet max([int compare(StyleSheet a, StyleSheet b)]) => _Collections.maxInList(this, compare);
StyleSheet removeAt(int pos) {
throw new UnsupportedError("Cannot removeAt on immutable List.");
@@ -22431,7 +24025,7 @@ class _DataAttributeMap implements Map<String, String> {
// interface Map
// TODO: Use lazy iterator when it is available on Map.
- bool containsValue(String value) => values.some((v) => v == value);
+ bool containsValue(String value) => values.any((v) => v == value);
bool containsKey(String key) => $dom_attributes.containsKey(_attr(key));
@@ -22654,7 +24248,7 @@ abstract class CssClassSet implements Set<String> {
bool get frozen => false;
// interface Iterable - BEGIN
- Iterator<String> iterator() => readClasses().iterator();
+ Iterator<String> get iterator => readClasses().iterator;
// interface Iterable - END
// interface Collection - BEGIN
@@ -22662,13 +24256,15 @@ abstract class CssClassSet implements Set<String> {
readClasses().forEach(f);
}
- Collection map(f(String element)) => readClasses().map(f);
+ String join([String separator]) => readClasses().join(separator);
- Collection<String> filter(bool f(String element)) => readClasses().filter(f);
+ Iterable mappedBy(f(String element)) => readClasses().mappedBy(f);
+
+ Iterable<String> where(bool f(String element)) => readClasses().where(f);
bool every(bool f(String element)) => readClasses().every(f);
- bool some(bool f(String element)) => readClasses().some(f);
+ bool any(bool f(String element)) => readClasses().any(f);
bool get isEmpty => readClasses().isEmpty;
@@ -22696,13 +24292,13 @@ abstract class CssClassSet implements Set<String> {
return result;
}
- void addAll(Collection<String> collection) {
+ void addAll(Iterable<String> iterable) {
// TODO - see comment above about validation
- _modify((s) => s.addAll(collection));
+ _modify((s) => s.addAll(iterable));
}
- void removeAll(Collection<String> collection) {
- _modify((s) => s.removeAll(collection));
+ void removeAll(Iterable<String> iterable) {
+ _modify((s) => s.removeAll(iterable));
}
bool isSubsetOf(Collection<String> collection) =>
@@ -22941,7 +24537,7 @@ class KeyboardEventController {
/** Determine if caps lock is one of the currently depressed keys. */
bool get _capsLockOn =>
- _keyDownList.some((var element) => element.keyCode == KeyCode.CAPS_LOCK);
+ _keyDownList.any((var element) => element.keyCode == KeyCode.CAPS_LOCK);
/**
* Given the previously recorded keydown key codes, see if we can determine
@@ -23170,7 +24766,7 @@ class KeyboardEventController {
// keyCode/which for non printable keys.
e._shadowKeyCode = _keyIdentifier[e._shadowKeyIdentifier];
}
- e._shadowAltKey = _keyDownList.some((var element) => element.altKey);
+ e._shadowAltKey = _keyDownList.any((var element) => element.altKey);
_dispatch(e);
}
@@ -23184,7 +24780,8 @@ class KeyboardEventController {
}
}
if (toRemove != null) {
- _keyDownList = _keyDownList.filter((element) => element != toRemove);
+ _keyDownList =
+ _keyDownList.where((element) => element != toRemove).toList();
} else if (_keyDownList.length > 0) {
// This happens when we've reached some international keyboard case we
// haven't accounted for or we haven't correctly eliminated all browser
@@ -24140,7 +25737,7 @@ class _RemoteSendPortSync implements SendPortSync {
var source = '$target-result';
var result = null;
var listener = (Event e) {
- result = JSON.parse(_getPortSyncEventData(e));
+ result = json.parse(_getPortSyncEventData(e));
};
window.on[source].add(listener);
_dispatchEvent(target, [source, message]);
@@ -24212,7 +25809,7 @@ class ReceivePortSync {
_callback = callback;
if (_listener == null) {
_listener = (Event e) {
- var data = JSON.parse(_getPortSyncEventData(e));
+ var data = json.parse(_getPortSyncEventData(e));
var replyTo = data[0];
var message = _deserialize(data[1]);
var result = _callback(message);
@@ -24243,7 +25840,7 @@ class ReceivePortSync {
get _isolateId => ReceivePortSync._isolateId;
void _dispatchEvent(String receiver, var message) {
- var event = new CustomEvent(receiver, false, false, JSON.stringify(message));
+ var event = new CustomEvent(receiver, false, false, json.stringify(message));
window.$dom_dispatchEvent(event);
}
@@ -24538,15 +26135,15 @@ abstract class _Serializer extends _MessageTraverser {
int id = _nextFreeRefId++;
_visited[map] = id;
- var keys = _serializeList(map.keys);
- var values = _serializeList(map.values);
+ var keys = _serializeList(map.keys.toList());
+ var values = _serializeList(map.values.toList());
// TODO(floitsch): we are losing the generic type.
return ['map', id, keys, values];
}
_serializeList(List list) {
int len = list.length;
- var result = new List(len);
+ var result = new List.fixedLength(len);
for (int i = 0; i < len; i++) {
result[i] = _dispatch(list[i]);
}
@@ -25274,31 +26871,53 @@ class Testing {
// Iterator for arrays with fixed size.
-class FixedSizeListIterator<T> extends _VariableSizeListIterator<T> {
+class FixedSizeListIterator<T> implements Iterator<T> {
+ final List<T> _array;
+ final int _length; // Cache array length for faster access.
+ int _position;
+ T _current;
+
FixedSizeListIterator(List<T> array)
- : super(array),
+ : _array = array,
+ _position = -1,
_length = array.length;
- bool get hasNext => _length > _pos;
+ bool moveNext() {
+ int nextPosition = _position + 1;
+ if (nextPosition < _length) {
+ _current = _array[nextPosition];
+ _position = nextPosition;
+ return true;
+ }
+ _current = null;
+ _position = _length;
+ return false;
+ }
- final int _length; // Cache array length for faster access.
+ T get current => _current;
}
// Iterator for arrays with variable size.
class _VariableSizeListIterator<T> implements Iterator<T> {
+ final List<T> _array;
+ int _position;
+ T _current;
+
_VariableSizeListIterator(List<T> array)
: _array = array,
- _pos = 0;
+ _position = -1;
- bool get hasNext => _array.length > _pos;
-
- T next() {
- if (!hasNext) {
- throw new StateError("No more elements");
+ bool moveNext() {
+ int nextPosition = _position + 1;
+ if (nextPosition < _array.length) {
+ _current = _array[nextPosition];
+ _position = nextPosition;
+ return true;
}
- return _array[_pos++];
+ _current = null;
+ _position = _array.length;
+ return false;
}
- final List<T> _array;
- int _pos;
+ T get current => _current;
}
« no previous file with comments | « sdk/lib/crypto/sha256.dart ('k') | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698