Rename XMatching to XWhere.

For example firstMatching -> firstWhere.

BUG= http://dartbug.com/8664
BUG= http://dartbug.com/8337

Review URL: https://codereview.chromium.org//12537009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19880 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
floitsch@google.com 2013-03-12 17:34:49 +00:00
parent 80a8c72128
commit 65718c56df
45 changed files with 1067 additions and 1067 deletions

View file

@ -331,7 +331,7 @@ class ArgParser {
* that abbreviation.
*/
Option findByAbbreviation(String abbr) {
return options.values.firstMatching((option) => option.abbreviation == abbr,
return options.values.firstWhere((option) => option.abbreviation == abbr,
orElse: () => null);
}
}

View file

@ -559,8 +559,8 @@ class _LazyList extends Iterable implements List {
removeLast() => _throw();
removeAll(x) => _throw();
retainAll(x) => _throw();
removeMatching(x) => _throw();
retainMatching(x) => _throw();
removeWhere(x) => _throw();
retainWhere(x) => _throw();
getRange(x, y) => _throw();
setRange(x, y, z, [a]) => _throw();
removeRange(x, y) => _throw();

View file

@ -48,7 +48,7 @@ main() {
// actually writing.
var w = new Writer(s);
w.write(p1);
var personRule = s.rules.firstMatching(
var personRule = s.rules.firstWhere(
(x) => x is BasicRule && x.type == reflect(p1).type);
var flatPerson = w.states[personRule.number].first;
var primStates = w.states.first;
@ -56,7 +56,7 @@ main() {
expect(flatPerson["name"], "Alice");
var ref = flatPerson["address"];
expect(ref is Reference, true);
var addressRule = s.rules.firstMatching(
var addressRule = s.rules.firstWhere(
(x) => x is BasicRule && x.type == reflect(a1).type);
expect(ref.ruleNumber, addressRule.number);
expect(ref.objectNumber, 0);
@ -213,7 +213,7 @@ main() {
w.write(n1);
expect(w.states.length, 5); // prims, lists, essential lists, basic
var children = 0, name = 1, parent = 2;
var nodeRule = s.rules.firstMatching((x) => x is BasicRule);
var nodeRule = s.rules.firstWhere((x) => x is BasicRule);
List rootNode = w.states[nodeRule.number].where(
(x) => x[name] == "1").toList();
rootNode = rootNode.first;
@ -476,8 +476,8 @@ main() {
var reader = s.newReader(eachFormat);
var input = reader.read(output);
expect(input["simple data"], data["simple data"]);
var p2 = input.keys.firstMatching((x) => x is Person);
var a2 = input.keys.firstMatching((x) => x is Address);
var p2 = input.keys.firstWhere((x) => x is Person);
var a2 = input.keys.firstWhere((x) => x is Address);
if (eachFormat is SimpleJsonFormat) {
// JSON doesn't handle cycles, so these won't be identical.
expect(input[p2] is Address, isTrue);
@ -502,7 +502,7 @@ main() {
var data = {"abc" : 1, "def" : "ghi"};
data["person"] = new Person()..name = "Foo";
var output = s.write(data, new SimpleMapFormat());
var mapRule = s.rules.firstMatching((x) => x is MapRule);
var mapRule = s.rules.firstWhere((x) => x is MapRule);
var map = output["data"][mapRule.number][0];
expect(map is Map, isTrue);
expect(map["abc"], 1);

View file

@ -689,7 +689,7 @@ void filterTests(testFilter) {
} else if (testFilter is Function) {
filterFunction = testFilter;
}
_tests.retainMatching(filterFunction);
_tests.retainWhere(filterFunction);
}
/** Runs all queued tests, one at a time. */

View file

@ -45,12 +45,12 @@ class _ObjectArray<E> implements List<E> {
"Cannot remove element of a non-extendable array");
}
void removeMatching(bool test(E element)) {
void removeWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot remove element of a non-extendable array");
}
void retainMatching(bool test(E element)) {
void retainWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot remove element of a non-extendable array");
}
@ -140,16 +140,16 @@ class _ObjectArray<E> implements List<E> {
return IterableMixinWorkaround.any(this, f);
}
E firstMatching(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
E firstWhere(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
E lastMatching(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
E lastWhere(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
E singleMatching(bool test(E value)) {
return IterableMixinWorkaround.singleMatching(this, test);
E singleWhere(bool test(E value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
E elementAt(int index) {
@ -285,12 +285,12 @@ class _ImmutableArray<E> implements List<E> {
"Cannot modify an immutable array");
}
void removeMatching(bool test(E element)) {
void removeWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot modify an immutable array");
}
void retainMatching(bool test(E element)) {
void retainWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot modify an immutable array");
}
@ -378,16 +378,16 @@ class _ImmutableArray<E> implements List<E> {
return IterableMixinWorkaround.any(this, f);
}
E firstMatching(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
E firstWhere(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
E lastMatching(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
E lastWhere(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
E singleMatching(bool test(E value)) {
return IterableMixinWorkaround.singleMatching(this, test);
E singleWhere(bool test(E value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
E elementAt(int index) {

View file

@ -274,16 +274,16 @@ abstract class _ByteArrayBase {
return IterableMixinWorkaround.any(this, f);
}
int firstMatching(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
int firstWhere(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
int lastMatching(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
int lastWhere(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
int singleMatching(bool test(int value)) {
return IterableMixinWorkaround.singleMatching(this, test);
int singleWhere(bool test(int value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
int elementAt(int index) {
@ -357,12 +357,12 @@ abstract class _ByteArrayBase {
"Cannot remove from a non-extendable array");
}
void removeMatching(bool test(int element)) {
void removeWhere(bool test(int element)) {
throw new UnsupportedError(
"Cannot remove from a non-extendable array");
}
void retainMatching(bool test(int element)) {
void retainWhere(bool test(int element)) {
throw new UnsupportedError(
"Cannot remove from a non-extendable array");
}
@ -2030,12 +2030,12 @@ class _ByteArrayViewBase extends Collection<int> {
"Cannot remove from a non-extendable array");
}
void removeMatching(bool test(int element)) {
void removeWhere(bool test(int element)) {
throw new UnsupportedError(
"Cannot remove from a non-extendable array");
}
void retainMatching(bool test(int element)) {
void retainWhere(bool test(int element)) {
throw new UnsupportedError(
"Cannot remove from a non-extendable array");
}

View file

@ -38,13 +38,13 @@ class _GrowableObjectArray<T> implements List<T> {
IterableMixinWorkaround.retainAll(this, elements);
}
void removeMatching(bool test(T element)) {
IterableMixinWorkaround.removeMatchingList(this, test);
void removeWhere(bool test(T element)) {
IterableMixinWorkaround.removeWhereList(this, test);
}
void retainMatching(bool test(T element)) {
IterableMixinWorkaround.removeMatchingList(this,
(T element) => !test(element));
void retainWhere(bool test(T element)) {
IterableMixinWorkaround.removeWhereList(this,
(T element) => !test(element));
}
void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
@ -278,16 +278,16 @@ class _GrowableObjectArray<T> implements List<T> {
return IterableMixinWorkaround.any(this, f);
}
T firstMatching(bool test(T value), {T orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
T firstWhere(bool test(T value), {T orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
T lastMatching(bool test(T value), {T orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
T lastWhere(bool test(T value), {T orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
T singleMatching(bool test(T value)) {
return IterableMixinWorkaround.singleMatching(this, test);
T singleWhere(bool test(T value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
T elementAt(int index) {

View file

@ -305,16 +305,16 @@ abstract class _TypedListBase {
return IterableMixinWorkaround.any(this, f);
}
int firstMatching(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
int firstWhere(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
int lastMatching(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
int lastWhere(bool test(int value), {int orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
int singleMatching(bool test(int value)) {
return IterableMixinWorkaround.singleMatching(this, test);
int singleWhere(bool test(int value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
int elementAt(int index) {
@ -384,12 +384,12 @@ abstract class _TypedListBase {
"Cannot remove from a non-extendable array");
}
void removeMatching(bool test(int element)) {
void removeWhere(bool test(int element)) {
throw new UnsupportedError(
"Cannot remove from a non-extendable array");
}
void retainMatching(bool test(int element)) {
void retainWhere(bool test(int element)) {
throw new UnsupportedError(
"Cannot remove from a non-extendable array");
}

View file

@ -79,7 +79,7 @@ abstract class ListIterable<E> extends Iterable<E> {
return false;
}
E firstMatching(bool test(E element), { E orElse() }) {
E firstWhere(bool test(E element), { E orElse() }) {
int length = this.length;
for (int i = 0; i < length; i++) {
E element = elementAt(i);
@ -92,7 +92,7 @@ abstract class ListIterable<E> extends Iterable<E> {
throw new StateError("No matching element");
}
E lastMatching(bool test(E element), { E orElse() }) {
E lastWhere(bool test(E element), { E orElse() }) {
int length = this.length;
for (int i = length - 1; i >= 0; i--) {
E element = elementAt(i);
@ -105,7 +105,7 @@ abstract class ListIterable<E> extends Iterable<E> {
throw new StateError("No matching element");
}
E singleMatching(bool test(E element)) {
E singleWhere(bool test(E element)) {
int length = this.length;
E match = null;
bool matchFound = false;
@ -644,17 +644,17 @@ class EmptyIterable<E> extends Iterable<E> {
bool any(bool test(E element)) => false;
E firstMatching(bool test(E element), { E orElse() }) {
E firstWhere(bool test(E element), { E orElse() }) {
if (orElse != null) return orElse();
throw new StateError("No matching element");
}
E lastMatching(bool test(E element), { E orElse() }) {
E lastWhere(bool test(E element), { E orElse() }) {
if (orElse != null) return orElse();
throw new StateError("No matching element");
}
E singleMatching(bool test(E element), { E orElse() }) {
E singleWhere(bool test(E element), { E orElse() }) {
if (orElse != null) return orElse();
throw new StateError("No matching element");
}

View file

@ -110,12 +110,12 @@ abstract class FixedLengthListBase<E> extends ListBase<E> {
"Cannot remove from a fixed-length list");
}
void removeMatching(bool test(E element)) {
void removeWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot remove from a fixed-length list");
}
void retainMatching(bool test(E element)) {
void retainWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot remove from a fixed-length list");
}
@ -191,12 +191,12 @@ abstract class UnmodifiableListBase<E> extends ListBase<E> {
"Cannot remove from an unmodifiable list");
}
void removeMatching(bool test(E element)) {
void removeWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot remove from an unmodifiable list");
}
void retainMatching(bool test(E element)) {
void retainWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot remove from an unmodifiable list");
}

View file

@ -51,14 +51,14 @@ class JSArray<E> implements List<E>, JSIndexable {
IterableMixinWorkaround.retainAll(this, elements);
}
void removeMatching(bool test(E element)) {
void removeWhere(bool test(E element)) {
// This could, and should, be optimized.
IterableMixinWorkaround.removeMatchingList(this, test);
IterableMixinWorkaround.removeWhereList(this, test);
}
void retainMatching(bool test(E element)) {
IterableMixinWorkaround.removeMatchingList(this,
(E element) => !test(element));
void retainWhere(bool test(E element)) {
IterableMixinWorkaround.removeWhereList(this,
(E element) => !test(element));
}
Iterable<E> where(bool f(E element)) {
@ -121,16 +121,16 @@ class JSArray<E> implements List<E>, JSIndexable {
return IterableMixinWorkaround.reduce(this, initialValue, combine);
}
E firstMatching(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
E firstWhere(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
E lastMatching(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
E lastWhere(bool test(E value), {E orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
E singleMatching(bool test(E value)) {
return IterableMixinWorkaround.singleMatching(this, test);
E singleWhere(bool test(E value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
E elementAt(int index) {

View file

@ -643,7 +643,7 @@ abstract class Stream<T> {
* with no [defaultValue] function provided, the future will receive an
* error.
*/
Future<T> firstMatching(bool test(T value), {T defaultValue()}) {
Future<T> firstWhere(bool test(T value), {T defaultValue()}) {
_FutureImpl<T> future = new _FutureImpl<T>();
StreamSubscription subscription;
subscription = this.listen(
@ -677,11 +677,11 @@ abstract class Stream<T> {
/**
* Finds the last element in this stream matching [test].
*
* As [firstMatching], except that the last matching element is found.
* As [firstWhere], except that the last matching element is found.
* That means that the result cannot be provided before this stream
* is done.
*/
Future<T> lastMatching(bool test(T value), {T defaultValue()}) {
Future<T> lastWhere(bool test(T value), {T defaultValue()}) {
_FutureImpl<T> future = new _FutureImpl<T>();
T result = null;
bool foundResult = false;
@ -724,7 +724,7 @@ abstract class Stream<T> {
* Like [lastMatch], except that it is an error if more than one
* matching element occurs in the stream.
*/
Future<T> singleMatching(bool test(T value)) {
Future<T> singleWhere(bool test(T value)) {
_FutureImpl<T> future = new _FutureImpl<T>();
T result = null;
bool foundResult = false;

View file

@ -74,13 +74,13 @@ class IterableMixinWorkaround {
} else {
setToRemove = elementsToRemove.toSet();
}
collection.removeMatching(setToRemove.contains);
collection.removeWhere(setToRemove.contains);
}
/**
* Simple implemenation for [Collection.retainAll].
*
* This implementation assumes that [Collecton.retainMatching] on [collection]
* This implementation assumes that [Collecton.retainWhere] on [collection]
* is efficient.
*/
static void retainAll(Collection collection, Iterable elementsToRetain) {
@ -94,16 +94,16 @@ class IterableMixinWorkaround {
collection.clear();
return;
}
collection.retainMatching(lookup.contains);
collection.retainWhere(lookup.contains);
}
/**
* Simple implemenation for [Collection.removeMatching].
* Simple implemenation for [Collection.removeWhere].
*
* This implementation assumes that [Collecton.removeAll] on [collection] is
* efficient.
*/
static void removeMatching(Collection collection, bool test(var element)) {
static void removeWhere(Collection collection, bool test(var element)) {
List elementsToRemove = [];
for (var element in collection) {
if (test(element)) elementsToRemove.add(element);
@ -118,7 +118,7 @@ class IterableMixinWorkaround {
* to the [test] function. First the elements to retain are found, and then
* the original list is updated to contain those elements.
*/
static void removeMatchingList(List list, bool test(var element)) {
static void removeWhereList(List list, bool test(var element)) {
List retained = [];
int length = list.length;
for (int i = 0; i < length; i++) {
@ -138,12 +138,12 @@ class IterableMixinWorkaround {
}
/**
* Simple implemenation for [Collection.retainMatching].
* Simple implemenation for [Collection.retainWhere].
*
* This implementation assumes that [Collecton.removeAll] on [collection] is
* efficient.
*/
static void retainMatching(Collection collection, bool test(var element)) {
static void retainWhere(Collection collection, bool test(var element)) {
List elementsToRemove = [];
for (var element in collection) {
if (!test(element)) elementsToRemove.add(element);
@ -209,7 +209,7 @@ class IterableMixinWorkaround {
return result;
}
static dynamic firstMatching(Iterable iterable,
static dynamic firstWhere(Iterable iterable,
bool test(dynamic value),
dynamic orElse()) {
for (dynamic element in iterable) {
@ -219,9 +219,9 @@ class IterableMixinWorkaround {
throw new StateError("No matching element");
}
static dynamic lastMatching(Iterable iterable,
bool test(dynamic value),
dynamic orElse()) {
static dynamic lastWhere(Iterable iterable,
bool test(dynamic value),
dynamic orElse()) {
dynamic result = null;
bool foundMatching = false;
for (dynamic element in iterable) {
@ -235,9 +235,9 @@ class IterableMixinWorkaround {
throw new StateError("No matching element");
}
static dynamic lastMatchingInList(List list,
bool test(dynamic value),
dynamic orElse()) {
static dynamic lastWhereList(List list,
bool test(dynamic value),
dynamic orElse()) {
// TODO(floitsch): check that arguments are of correct type?
for (int i = list.length - 1; i >= 0; i--) {
dynamic element = list[i];
@ -247,7 +247,7 @@ class IterableMixinWorkaround {
throw new StateError("No matching element");
}
static dynamic singleMatching(Iterable iterable, bool test(dynamic value)) {
static dynamic singleWhere(Iterable iterable, bool test(dynamic value)) {
dynamic result = null;
bool foundMatching = false;
for (dynamic element in iterable) {

View file

@ -55,7 +55,7 @@ class HashSet<E> extends Collection<E> implements Set<E> {
IterableMixinWorkaround.retainAll(this, objectsToRetain);
}
void _filterMatching(bool test(E element), bool removeMatching) {
void _filterWhere(bool test(E element), bool removeMatching) {
int entrySize = _table._entrySize;
int length = _table._table.length;
for (int offset = 0; offset < length; offset += entrySize) {
@ -73,12 +73,12 @@ class HashSet<E> extends Collection<E> implements Set<E> {
_table._checkCapacity();
}
void removeMatching(bool test(E element)) {
_filterMatching(test, true);
void removeWhere(bool test(E element)) {
_filterWhere(test, true);
}
void retainMatching(bool test(E element)) {
_filterMatching(test, false);
void retainWhere(bool test(E element)) {
_filterWhere(test, false);
}
void clear() {

View file

@ -97,7 +97,7 @@ class LinkedHashSet<E> extends Collection<E> implements Set<E> {
IterableMixinWorkaround.retainAll(this, objectsToRemove);
}
void _filterMatching(bool test(E element), bool removeMatching) {
void _filterWhere(bool test(E element), bool removeMatching) {
int entrySize = _table._entrySize;
int length = _table._table.length;
int offset = _table._next(_LinkedHashTable._HEAD_OFFSET);
@ -115,12 +115,12 @@ class LinkedHashSet<E> extends Collection<E> implements Set<E> {
_table._checkCapacity();
}
void removeMatching(bool test(E element)) {
_filterMatching(test, true);
void removeWhere(bool test(E element)) {
_filterWhere(test, true);
}
void retainMatching(bool test(E element)) {
_filterMatching(test, false);
void retainWhere(bool test(E element)) {
_filterWhere(test, false);
}
void clear() {

View file

@ -225,11 +225,11 @@ class DoubleLinkedQueue<E> extends Collection<E> implements Queue<E> {
}
void removeAll(Iterable elements) {
// Use this method when remove is slow and removeMatching more efficient.
// Use this method when remove is slow and removeWhere more efficient.
IterableMixinWorkaround.removeAllList(this, elements);
}
void removeMatching(bool test(E element)) {
void removeWhere(bool test(E element)) {
DoubleLinkedQueueEntry<E> entry = firstEntry();
while (!identical(entry, _sentinel)) {
DoubleLinkedQueueEntry<E> next = entry._next;
@ -241,7 +241,7 @@ class DoubleLinkedQueue<E> extends Collection<E> implements Queue<E> {
}
}
void retainMatching(bool test(E element)) {
void retainWhere(bool test(E element)) {
DoubleLinkedQueueEntry<E> entry = firstEntry();
while (!identical(entry, _sentinel)) {
DoubleLinkedQueueEntry<E> next = entry._next;
@ -342,7 +342,7 @@ class _DoubleLinkedQueueIterator<E> implements Iterator<E> {
*
* The structure is efficient for any queue or stack usage.
*
* Collection operations like [removeAll] and [removeMatching] are very
* Collection operations like [removeAll] and [removeWhere] are very
* inefficient. If those are needed, use a [DoubleLinkedQueue] instead.
*/
class ListQueue<E> extends Collection<E> implements Queue<E>{
@ -489,7 +489,7 @@ class ListQueue<E> extends Collection<E> implements Queue<E>{
IterableMixinWorkaround.retainAll(this, objectsToRetain);
}
void _filterMatching(bool test(E element), bool removeMatching) {
void _filterWhere(bool test(E element), bool removeMatching) {
int index = _head;
int modificationCount = _modificationCount;
int i = _head;
@ -512,8 +512,8 @@ class ListQueue<E> extends Collection<E> implements Queue<E>{
* This method is inefficient since it works by repeatedly removing single
* elements, each of which can take linear time.
*/
void removeMatching(bool test(E element)) {
_filterMatching(test, true);
void removeWhere(bool test(E element)) {
_filterWhere(test, true);
}
/**
@ -522,8 +522,8 @@ class ListQueue<E> extends Collection<E> implements Queue<E>{
* This method is inefficient since it works by repeatedly removing single
* elements, each of which can take linear time.
*/
void retainMatching(bool test(E element)) {
_filterMatching(test, false);
void retainWhere(bool test(E element)) {
_filterWhere(test, false);
}
void clear() {

View file

@ -72,8 +72,8 @@ abstract class Collection<E> extends Iterable<E> {
*
* An elements [:e:] satisfies [test] if [:test(e):] is true.
*/
void removeMatching(bool test(E element)) {
IterableMixinWorkaround.removeMatching(this, test);
void removeWhere(bool test(E element)) {
IterableMixinWorkaround.removeWhere(this, test);
}
/**
@ -81,14 +81,14 @@ abstract class Collection<E> extends Iterable<E> {
*
* An elements [:e:] satisfies [test] if [:test(e):] is true.
*/
void retainMatching(bool test(E element)) {
IterableMixinWorkaround.retainMatching(this, test);
void retainWhere(bool test(E element)) {
IterableMixinWorkaround.retainWhere(this, test);
}
/**
* Removes all elements of this collection.
*/
void clear() {
IterableMixinWorkaround.removeMatching(this, (E e) => true);
IterableMixinWorkaround.removeWhere(this, (E e) => true);
}
}

View file

@ -323,7 +323,7 @@ abstract class Iterable<E> {
* returned. By default, when [orElse] is `null`, a [StateError] is
* thrown.
*/
E firstMatching(bool test(E value), { E orElse() }) {
E firstWhere(bool test(E value), { E orElse() }) {
// TODO(floitsch): check that arguments are of correct type?
for (E element in this) {
if (test(element)) return element;
@ -339,7 +339,7 @@ abstract class Iterable<E> {
* returned. By default, when [orElse] is [:null:], a [StateError] is
* thrown.
*/
E lastMatching(bool test(E value), {E orElse()}) {
E lastWhere(bool test(E value), {E orElse()}) {
// TODO(floitsch): check that arguments are of correct type?
E result = null;
bool foundMatching = false;
@ -358,7 +358,7 @@ abstract class Iterable<E> {
* Returns the single element that satisfies [f]. If no or more than one
* element match then a [StateError] is thrown.
*/
E singleMatching(bool test(E value)) {
E singleWhere(bool test(E value)) {
// TODO(floitsch): check that argument is of correct type?
E result = null;
bool foundMatching = false;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -133,12 +133,12 @@ class FilteredElementList implements List {
IterableMixinWorkaround.retainAll(this, elements);
}
void removeMatching(bool test(Element element)) {
IterableMixinWorkaround.removeMatching(this, test);
void removeWhere(bool test(Element element)) {
IterableMixinWorkaround.removeWhere(this, test);
}
void retainMatching(bool test(Element element)) {
IterableMixinWorkaround.retainMatching(this, test);
void retainWhere(bool test(Element element)) {
IterableMixinWorkaround.retainWhere(this, test);
}
dynamic reduce(dynamic initialValue,
@ -150,16 +150,16 @@ class FilteredElementList implements List {
List<Element> toList({ bool growable: true }) =>
new List<Element>.from(this, growable: growable);
Set<Element> toSet() => new Set<Element>.from(this);
Element firstMatching(bool test(Element value), {Element orElse()}) {
return _filtered.firstMatching(test, orElse: orElse);
Element firstWhere(bool test(Element value), {Element orElse()}) {
return _filtered.firstWhere(test, orElse: orElse);
}
Element lastMatching(bool test(Element value), {Element orElse()}) {
return _filtered.lastMatching(test, orElse: orElse);
Element lastWhere(bool test(Element value), {Element orElse()}) {
return _filtered.lastWhere(test, orElse: orElse);
}
Element singleMatching(bool test(Element value)) {
return _filtered.singleMatching(test);
Element singleWhere(bool test(Element value)) {
return _filtered.singleWhere(test);
}
Element elementAt(int index) {

View file

@ -3112,16 +3112,16 @@ class LengthList implements JavaScriptIndexingBehavior, List<Length> native "*SV
return IterableMixinWorkaround.skipWhile(this, test);
}
Length firstMatching(bool test(Length value), { Length orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Length firstWhere(bool test(Length value), { Length orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Length lastMatching(bool test(Length value), {Length orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Length lastWhere(bool test(Length value), {Length orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Length singleMatching(bool test(Length value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Length singleWhere(bool test(Length value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Length elementAt(int index) {
@ -3207,11 +3207,11 @@ class LengthList implements JavaScriptIndexingBehavior, List<Length> native "*SV
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Length element)) {
void removeWhere(bool test(Length element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Length element)) {
void retainWhere(bool test(Length element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -3741,16 +3741,16 @@ class NumberList implements JavaScriptIndexingBehavior, List<Number> native "*SV
return IterableMixinWorkaround.skipWhile(this, test);
}
Number firstMatching(bool test(Number value), { Number orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Number firstWhere(bool test(Number value), { Number orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Number lastMatching(bool test(Number value), {Number orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Number lastWhere(bool test(Number value), {Number orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Number singleMatching(bool test(Number value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Number singleWhere(bool test(Number value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Number elementAt(int index) {
@ -3836,11 +3836,11 @@ class NumberList implements JavaScriptIndexingBehavior, List<Number> native "*SV
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Number element)) {
void removeWhere(bool test(Number element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Number element)) {
void retainWhere(bool test(Number element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -4646,16 +4646,16 @@ class PathSegList implements JavaScriptIndexingBehavior, List<PathSeg> native "*
return IterableMixinWorkaround.skipWhile(this, test);
}
PathSeg firstMatching(bool test(PathSeg value), { PathSeg orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
PathSeg firstWhere(bool test(PathSeg value), { PathSeg orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
PathSeg lastMatching(bool test(PathSeg value), {PathSeg orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
PathSeg lastWhere(bool test(PathSeg value), {PathSeg orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
PathSeg singleMatching(bool test(PathSeg value)) {
return IterableMixinWorkaround.singleMatching(this, test);
PathSeg singleWhere(bool test(PathSeg value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
PathSeg elementAt(int index) {
@ -4741,11 +4741,11 @@ class PathSegList implements JavaScriptIndexingBehavior, List<PathSeg> native "*
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(PathSeg element)) {
void removeWhere(bool test(PathSeg element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(PathSeg element)) {
void retainWhere(bool test(PathSeg element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -5536,16 +5536,16 @@ class StringList implements JavaScriptIndexingBehavior, List<String> native "*SV
return IterableMixinWorkaround.skipWhile(this, test);
}
String firstMatching(bool test(String value), { String orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
String firstWhere(bool test(String value), { String orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
String lastMatching(bool test(String value), {String orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
String lastWhere(bool test(String value), {String orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
String singleMatching(bool test(String value)) {
return IterableMixinWorkaround.singleMatching(this, test);
String singleWhere(bool test(String value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
String elementAt(int index) {
@ -5631,11 +5631,11 @@ class StringList implements JavaScriptIndexingBehavior, List<String> native "*SV
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(String element)) {
void removeWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(String element)) {
void retainWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -6703,16 +6703,16 @@ class TransformList implements List<Transform>, JavaScriptIndexingBehavior nativ
return IterableMixinWorkaround.skipWhile(this, test);
}
Transform firstMatching(bool test(Transform value), { Transform orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Transform firstWhere(bool test(Transform value), { Transform orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Transform lastMatching(bool test(Transform value), {Transform orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Transform lastWhere(bool test(Transform value), {Transform orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Transform singleMatching(bool test(Transform value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Transform singleWhere(bool test(Transform value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Transform elementAt(int index) {
@ -6798,11 +6798,11 @@ class TransformList implements List<Transform>, JavaScriptIndexingBehavior nativ
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Transform element)) {
void removeWhere(bool test(Transform element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Transform element)) {
void retainWhere(bool test(Transform element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -7225,16 +7225,16 @@ class _ElementInstanceList implements JavaScriptIndexingBehavior, List<ElementIn
return IterableMixinWorkaround.skipWhile(this, test);
}
ElementInstance firstMatching(bool test(ElementInstance value), { ElementInstance orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
ElementInstance firstWhere(bool test(ElementInstance value), { ElementInstance orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
ElementInstance lastMatching(bool test(ElementInstance value), {ElementInstance orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
ElementInstance lastWhere(bool test(ElementInstance value), {ElementInstance orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
ElementInstance singleMatching(bool test(ElementInstance value)) {
return IterableMixinWorkaround.singleMatching(this, test);
ElementInstance singleWhere(bool test(ElementInstance value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
ElementInstance elementAt(int index) {
@ -7322,11 +7322,11 @@ class _ElementInstanceList implements JavaScriptIndexingBehavior, List<ElementIn
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(ElementInstance element)) {
void removeWhere(bool test(ElementInstance element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(ElementInstance element)) {
void retainWhere(bool test(ElementInstance element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}

View file

@ -3375,16 +3375,16 @@ class LengthList extends NativeFieldWrapperClass1 implements List<Length> {
return IterableMixinWorkaround.skipWhile(this, test);
}
Length firstMatching(bool test(Length value), { Length orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Length firstWhere(bool test(Length value), { Length orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Length lastMatching(bool test(Length value), {Length orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Length lastWhere(bool test(Length value), {Length orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Length singleMatching(bool test(Length value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Length singleWhere(bool test(Length value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Length elementAt(int index) {
@ -3470,11 +3470,11 @@ class LengthList extends NativeFieldWrapperClass1 implements List<Length> {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Length element)) {
void removeWhere(bool test(Length element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Length element)) {
void retainWhere(bool test(Length element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -4081,16 +4081,16 @@ class NumberList extends NativeFieldWrapperClass1 implements List<Number> {
return IterableMixinWorkaround.skipWhile(this, test);
}
Number firstMatching(bool test(Number value), { Number orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Number firstWhere(bool test(Number value), { Number orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Number lastMatching(bool test(Number value), {Number orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Number lastWhere(bool test(Number value), {Number orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Number singleMatching(bool test(Number value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Number singleWhere(bool test(Number value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Number elementAt(int index) {
@ -4176,11 +4176,11 @@ class NumberList extends NativeFieldWrapperClass1 implements List<Number> {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Number element)) {
void removeWhere(bool test(Number element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Number element)) {
void retainWhere(bool test(Number element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -5263,16 +5263,16 @@ class PathSegList extends NativeFieldWrapperClass1 implements List<PathSeg> {
return IterableMixinWorkaround.skipWhile(this, test);
}
PathSeg firstMatching(bool test(PathSeg value), { PathSeg orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
PathSeg firstWhere(bool test(PathSeg value), { PathSeg orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
PathSeg lastMatching(bool test(PathSeg value), {PathSeg orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
PathSeg lastWhere(bool test(PathSeg value), {PathSeg orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
PathSeg singleMatching(bool test(PathSeg value)) {
return IterableMixinWorkaround.singleMatching(this, test);
PathSeg singleWhere(bool test(PathSeg value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
PathSeg elementAt(int index) {
@ -5358,11 +5358,11 @@ class PathSegList extends NativeFieldWrapperClass1 implements List<PathSeg> {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(PathSeg element)) {
void removeWhere(bool test(PathSeg element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(PathSeg element)) {
void retainWhere(bool test(PathSeg element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -6250,16 +6250,16 @@ class StringList extends NativeFieldWrapperClass1 implements List<String> {
return IterableMixinWorkaround.skipWhile(this, test);
}
String firstMatching(bool test(String value), { String orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
String firstWhere(bool test(String value), { String orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
String lastMatching(bool test(String value), {String orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
String lastWhere(bool test(String value), {String orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
String singleMatching(bool test(String value)) {
return IterableMixinWorkaround.singleMatching(this, test);
String singleWhere(bool test(String value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
String elementAt(int index) {
@ -6345,11 +6345,11 @@ class StringList extends NativeFieldWrapperClass1 implements List<String> {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(String element)) {
void removeWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(String element)) {
void retainWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -7506,16 +7506,16 @@ class TransformList extends NativeFieldWrapperClass1 implements List<Transform>
return IterableMixinWorkaround.skipWhile(this, test);
}
Transform firstMatching(bool test(Transform value), { Transform orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Transform firstWhere(bool test(Transform value), { Transform orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Transform lastMatching(bool test(Transform value), {Transform orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Transform lastWhere(bool test(Transform value), {Transform orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Transform singleMatching(bool test(Transform value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Transform singleWhere(bool test(Transform value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Transform elementAt(int index) {
@ -7601,11 +7601,11 @@ class TransformList extends NativeFieldWrapperClass1 implements List<Transform>
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Transform element)) {
void removeWhere(bool test(Transform element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Transform element)) {
void retainWhere(bool test(Transform element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@ -8082,16 +8082,16 @@ class _ElementInstanceList extends NativeFieldWrapperClass1 implements List<Elem
return IterableMixinWorkaround.skipWhile(this, test);
}
ElementInstance firstMatching(bool test(ElementInstance value), { ElementInstance orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
ElementInstance firstWhere(bool test(ElementInstance value), { ElementInstance orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
ElementInstance lastMatching(bool test(ElementInstance value), {ElementInstance orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
ElementInstance lastWhere(bool test(ElementInstance value), {ElementInstance orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
ElementInstance singleMatching(bool test(ElementInstance value)) {
return IterableMixinWorkaround.singleMatching(this, test);
ElementInstance singleWhere(bool test(ElementInstance value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
ElementInstance elementAt(int index) {
@ -8179,11 +8179,11 @@ class _ElementInstanceList extends NativeFieldWrapperClass1 implements List<Elem
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(ElementInstance element)) {
void removeWhere(bool test(ElementInstance element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(ElementInstance element)) {
void retainWhere(bool test(ElementInstance element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}

View file

@ -306,16 +306,16 @@ class SqlResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
return IterableMixinWorkaround.skipWhile(this, test);
}
Map firstMatching(bool test(Map value), { Map orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Map firstWhere(bool test(Map value), { Map orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Map lastMatching(bool test(Map value), {Map orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Map lastWhere(bool test(Map value), {Map orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Map singleMatching(bool test(Map value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Map singleWhere(bool test(Map value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Map elementAt(int index) {
@ -403,11 +403,11 @@ class SqlResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Map element)) {
void removeWhere(bool test(Map element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Map element)) {
void retainWhere(bool test(Map element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}

View file

@ -328,16 +328,16 @@ class SqlResultSetRowList extends NativeFieldWrapperClass1 implements List<Map>
return IterableMixinWorkaround.skipWhile(this, test);
}
Map firstMatching(bool test(Map value), { Map orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Map firstWhere(bool test(Map value), { Map orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Map lastMatching(bool test(Map value), {Map orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Map lastWhere(bool test(Map value), {Map orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Map singleMatching(bool test(Map value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Map singleWhere(bool test(Map value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Map elementAt(int index) {
@ -425,11 +425,11 @@ class SqlResultSetRowList extends NativeFieldWrapperClass1 implements List<Map>
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test(Map element)) {
void removeWhere(bool test(Map element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test(Map element)) {
void retainWhere(bool test(Map element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}

View file

@ -45,15 +45,15 @@ testRetainAll(Collection base, Iterable retains) {
}
}
testRemoveMatching(Collection base, bool test(value)) {
testRemoveWhere(Collection base, bool test(value)) {
Set retained = new Set();
for (var element in base) {
if (!test(element)) {
retained.add(element);
}
}
String name = "$base.removeMatching(...) -> $retained";
base.removeMatching(test);
String name = "$base.removeWhere(...) -> $retained";
base.removeWhere(test);
for (var value in base) {
Expect.isFalse(test(value), "$name: Found $value");
}
@ -62,15 +62,15 @@ testRemoveMatching(Collection base, bool test(value)) {
}
}
testRetainMatching(Collection base, bool test(value)) {
testRetainWhere(Collection base, bool test(value)) {
Set retained = new Set();
for (var element in base) {
if (test(element)) {
retained.add(element);
}
}
String name = "$base.retainMatching(...) -> $retained";
base.retainMatching(test);
String name = "$base.retainWhere(...) -> $retained";
base.retainWhere(test);
for (var value in base) {
Expect.isTrue(test(value), "$name: Found $value");
}
@ -94,16 +94,16 @@ void main() {
testRemoveAll(base.toList(), deltaSet);
testRetainAll(base.toList(), delta);
testRetainAll(base.toList(), deltaSet);
testRemoveMatching(base.toList(), deltaSet.contains);
testRetainMatching(base.toList(),
testRemoveWhere(base.toList(), deltaSet.contains);
testRetainWhere(base.toList(),
(e) => !deltaSet.contains(e));
testRemoveAll(base.toSet(), delta);
testRemoveAll(base.toSet(), deltaSet);
testRetainAll(base.toSet(), delta);
testRetainAll(base.toSet(), deltaSet);
testRemoveMatching(base.toSet(), deltaSet.contains);
testRetainMatching(base.toSet(), (e) => !deltaSet.contains(e));
testRemoveWhere(base.toSet(), deltaSet.contains);
testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e));
}
}
}

View file

@ -1,46 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
List<String> list3 = <String>[];
Set<int> set1 = new Set<int>();
set1..add(11)
..add(12)
..add(13);
Set set2 = new Set();
Expect.equals(2, list1.firstMatching((x) => x.isEven));
Expect.equals(1, list1.firstMatching((x) => x.isOdd));
Expect.throws(() => list1.firstMatching((x) => x > 3),
(e) => e is StateError);
Expect.equals(null, list1.firstMatching((x) => x > 3, orElse: () => null));
Expect.equals(499, list1.firstMatching((x) => x > 3, orElse: () => 499));
Expect.equals(4, list2.firstMatching((x) => x.isEven));
Expect.equals(5, list2.firstMatching((x) => x.isOdd));
Expect.throws(() => list2.firstMatching((x) => x == 0),
(e) => e is StateError);
Expect.equals(null, list2.firstMatching((x) => false, orElse: () => null));
Expect.equals(499, list2.firstMatching((x) => false, orElse: () => 499));
Expect.throws(() => list3.firstMatching((x) => x == 0),
(e) => e is StateError);
Expect.throws(() => list3.firstMatching((x) => true), (e) => e is StateError);
Expect.equals(null, list3.firstMatching((x) => true, orElse: () => null));
Expect.equals("str", list3.firstMatching((x) => false, orElse: () => "str"));
Expect.equals(12, set1.firstMatching((x) => x.isEven));
var odd = set1.firstMatching((x) => x.isOdd);
Expect.isTrue(odd == 11 || odd == 13);
Expect.throws(() => set1.firstMatching((x) => false), (e) => e is StateError);
Expect.equals(null, set1.firstMatching((x) => false, orElse: () => null));
Expect.equals(499, set1.firstMatching((x) => false, orElse: () => 499));
Expect.throws(() => set2.firstMatching((x) => false), (e) => e is StateError);
Expect.throws(() => set2.firstMatching((x) => true), (e) => e is StateError);
Expect.equals(null, set2.firstMatching((x) => true, orElse: () => null));
Expect.equals(499, set2.firstMatching((x) => false, orElse: () => 499));
}

View file

@ -0,0 +1,46 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
List<String> list3 = <String>[];
Set<int> set1 = new Set<int>();
set1..add(11)
..add(12)
..add(13);
Set set2 = new Set();
Expect.equals(2, list1.firstWhere((x) => x.isEven));
Expect.equals(1, list1.firstWhere((x) => x.isOdd));
Expect.throws(() => list1.firstWhere((x) => x > 3),
(e) => e is StateError);
Expect.equals(null, list1.firstWhere((x) => x > 3, orElse: () => null));
Expect.equals(499, list1.firstWhere((x) => x > 3, orElse: () => 499));
Expect.equals(4, list2.firstWhere((x) => x.isEven));
Expect.equals(5, list2.firstWhere((x) => x.isOdd));
Expect.throws(() => list2.firstWhere((x) => x == 0),
(e) => e is StateError);
Expect.equals(null, list2.firstWhere((x) => false, orElse: () => null));
Expect.equals(499, list2.firstWhere((x) => false, orElse: () => 499));
Expect.throws(() => list3.firstWhere((x) => x == 0),
(e) => e is StateError);
Expect.throws(() => list3.firstWhere((x) => true), (e) => e is StateError);
Expect.equals(null, list3.firstWhere((x) => true, orElse: () => null));
Expect.equals("str", list3.firstWhere((x) => false, orElse: () => "str"));
Expect.equals(12, set1.firstWhere((x) => x.isEven));
var odd = set1.firstWhere((x) => x.isOdd);
Expect.isTrue(odd == 11 || odd == 13);
Expect.throws(() => set1.firstWhere((x) => false), (e) => e is StateError);
Expect.equals(null, set1.firstWhere((x) => false, orElse: () => null));
Expect.equals(499, set1.firstWhere((x) => false, orElse: () => 499));
Expect.throws(() => set2.firstWhere((x) => false), (e) => e is StateError);
Expect.throws(() => set2.firstWhere((x) => true), (e) => e is StateError);
Expect.equals(null, set2.firstWhere((x) => true, orElse: () => null));
Expect.equals(499, set2.firstWhere((x) => false, orElse: () => 499));
}

View file

@ -1,46 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5, 6];
List<String> list3 = <String>[];
Set<int> set1 = new Set<int>();
set1..add(11)
..add(12)
..add(13);
Set set2 = new Set();
Expect.equals(2, list1.lastMatching((x) => x.isEven));
Expect.equals(3, list1.lastMatching((x) => x.isOdd));
Expect.throws(() => list1.lastMatching((x) => x > 3),
(e) => e is StateError);
Expect.equals(null, list1.lastMatching((x) => x > 3, orElse: () => null));
Expect.equals(499, list1.lastMatching((x) => x > 3, orElse: () => 499));
Expect.equals(6, list2.lastMatching((x) => x.isEven));
Expect.equals(5, list2.lastMatching((x) => x.isOdd));
Expect.throws(() => list2.lastMatching((x) => x == 0),
(e) => e is StateError);
Expect.equals(null, list2.lastMatching((x) => false, orElse: () => null));
Expect.equals(499, list2.lastMatching((x) => false, orElse: () => 499));
Expect.throws(() => list3.lastMatching((x) => x == 0),
(e) => e is StateError);
Expect.throws(() => list3.lastMatching((x) => true), (e) => e is StateError);
Expect.equals(null, list3.lastMatching((x) => true, orElse: () => null));
Expect.equals("str", list3.lastMatching((x) => false, orElse: () => "str"));
Expect.equals(12, set1.lastMatching((x) => x.isEven));
var odd = set1.lastMatching((x) => x.isOdd);
Expect.isTrue(odd == 11 || odd == 13);
Expect.throws(() => set1.lastMatching((x) => false), (e) => e is StateError);
Expect.equals(null, set1.lastMatching((x) => false, orElse: () => null));
Expect.equals(499, set1.lastMatching((x) => false, orElse: () => 499));
Expect.throws(() => set2.lastMatching((x) => false), (e) => e is StateError);
Expect.throws(() => set2.lastMatching((x) => true), (e) => e is StateError);
Expect.equals(null, set2.lastMatching((x) => true, orElse: () => null));
Expect.equals(499, set2.lastMatching((x) => false, orElse: () => 499));
}

View file

@ -0,0 +1,46 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5, 6];
List<String> list3 = <String>[];
Set<int> set1 = new Set<int>();
set1..add(11)
..add(12)
..add(13);
Set set2 = new Set();
Expect.equals(2, list1.lastWhere((x) => x.isEven));
Expect.equals(3, list1.lastWhere((x) => x.isOdd));
Expect.throws(() => list1.lastWhere((x) => x > 3),
(e) => e is StateError);
Expect.equals(null, list1.lastWhere((x) => x > 3, orElse: () => null));
Expect.equals(499, list1.lastWhere((x) => x > 3, orElse: () => 499));
Expect.equals(6, list2.lastWhere((x) => x.isEven));
Expect.equals(5, list2.lastWhere((x) => x.isOdd));
Expect.throws(() => list2.lastWhere((x) => x == 0),
(e) => e is StateError);
Expect.equals(null, list2.lastWhere((x) => false, orElse: () => null));
Expect.equals(499, list2.lastWhere((x) => false, orElse: () => 499));
Expect.throws(() => list3.lastWhere((x) => x == 0),
(e) => e is StateError);
Expect.throws(() => list3.lastWhere((x) => true), (e) => e is StateError);
Expect.equals(null, list3.lastWhere((x) => true, orElse: () => null));
Expect.equals("str", list3.lastWhere((x) => false, orElse: () => "str"));
Expect.equals(12, set1.lastWhere((x) => x.isEven));
var odd = set1.lastWhere((x) => x.isOdd);
Expect.isTrue(odd == 11 || odd == 13);
Expect.throws(() => set1.lastWhere((x) => false), (e) => e is StateError);
Expect.equals(null, set1.lastWhere((x) => false, orElse: () => null));
Expect.equals(499, set1.lastWhere((x) => false, orElse: () => 499));
Expect.throws(() => set2.lastWhere((x) => false), (e) => e is StateError);
Expect.throws(() => set2.lastWhere((x) => true), (e) => e is StateError);
Expect.equals(null, set2.lastWhere((x) => true, orElse: () => null));
Expect.equals(499, set2.lastWhere((x) => false, orElse: () => 499));
}

View file

@ -1,33 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5, 6];
List<String> list3 = <String>[];
Set<int> set1 = new Set<int>();
set1..add(11)
..add(12)
..add(13);
Set set2 = new Set();
Expect.equals(2, list1.singleMatching((x) => x.isEven));
Expect.equals(3, list1.singleMatching((x) => x == 3));
Expect.throws(() => list1.singleMatching((x) => x.isOdd),
(e) => e is StateError);
Expect.equals(6, list2.singleMatching((x) => x == 6));
Expect.equals(5, list2.singleMatching((x) => x.isOdd));
Expect.throws(() => list2.singleMatching((x) => x.isEven),
(e) => e is StateError);
Expect.throws(() => list3.singleMatching((x) => x == 0),
(e) => e is StateError);
Expect.equals(12, set1.singleMatching((x) => x.isEven));
Expect.equals(11, set1.singleMatching((x) => x == 11));
Expect.throws(() => set1.singleMatching((x) => x.isOdd));
Expect.throws(() => set2.singleMatching((x) => true), (e) => e is StateError);
}

View file

@ -0,0 +1,33 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5, 6];
List<String> list3 = <String>[];
Set<int> set1 = new Set<int>();
set1..add(11)
..add(12)
..add(13);
Set set2 = new Set();
Expect.equals(2, list1.singleWhere((x) => x.isEven));
Expect.equals(3, list1.singleWhere((x) => x == 3));
Expect.throws(() => list1.singleWhere((x) => x.isOdd),
(e) => e is StateError);
Expect.equals(6, list2.singleWhere((x) => x == 6));
Expect.equals(5, list2.singleWhere((x) => x.isOdd));
Expect.throws(() => list2.singleWhere((x) => x.isEven),
(e) => e is StateError);
Expect.throws(() => list3.singleWhere((x) => x == 0),
(e) => e is StateError);
Expect.equals(12, set1.singleWhere((x) => x.isEven));
Expect.equals(11, set1.singleWhere((x) => x == 11));
Expect.throws(() => set1.singleWhere((x) => x.isOdd));
Expect.throws(() => set2.singleWhere((x) => true), (e) => e is StateError);
}

View file

@ -95,18 +95,18 @@ void testOperations() {
testOp((i) => i.first, "first");
testOp((i) => i.last, "last");
testOp((i) => i.single, "single");
testOp((i) => i.firstMatching((n) => false), "firstMatching<false");
testOp((i) => i.firstMatching((n) => n < 10), "firstMatching<10");
testOp((i) => i.firstMatching((n) => n < 5), "firstMatching<5");
testOp((i) => i.firstMatching((n) => true), "firstMatching<true");
testOp((i) => i.lastMatching((n) => false), "lastMatching<false");
testOp((i) => i.lastMatching((n) => n < 5), "lastMatching<5");
testOp((i) => i.lastMatching((n) => n < 10), "lastMatching<10");
testOp((i) => i.lastMatching((n) => true), "lastMatching<true");
testOp((i) => i.singleMatching((n) => false), "singleMatching<false");
testOp((i) => i.singleMatching((n) => n < 5), "singelMatching<5");
testOp((i) => i.singleMatching((n) => n < 10), "singelMatching<10");
testOp((i) => i.singleMatching((n) => true), "singleMatching<true");
testOp((i) => i.firstWhere((n) => false), "firstWhere<false");
testOp((i) => i.firstWhere((n) => n < 10), "firstWhere<10");
testOp((i) => i.firstWhere((n) => n < 5), "firstWhere<5");
testOp((i) => i.firstWhere((n) => true), "firstWhere<true");
testOp((i) => i.lastWhere((n) => false), "lastWhere<false");
testOp((i) => i.lastWhere((n) => n < 5), "lastWhere<5");
testOp((i) => i.lastWhere((n) => n < 10), "lastWhere<10");
testOp((i) => i.lastWhere((n) => true), "lastWhere<true");
testOp((i) => i.singleWhere((n) => false), "singleWhere<false");
testOp((i) => i.singleWhere((n) => n < 5), "singelWhere<5");
testOp((i) => i.singleWhere((n) => n < 10), "singelWhere<10");
testOp((i) => i.singleWhere((n) => true), "singleWhere<true");
testOp((i) => i.contains(5), "contains(5)");
testOp((i) => i.contains(10), "contains(10)");
testOp((i) => i.any((n) => n < 5), "any<5");

View file

@ -92,12 +92,12 @@ void testOperations() {
testOp((i) => i.first, "first");
testOp((i) => i.last, "last");
testOp((i) => i.single, "single");
testOp((i) => i.firstMatching((n) => n < 5), "firstMatching<5");
testOp((i) => i.firstMatching((n) => n < 10), "firstMatching<10");
testOp((i) => i.lastMatching((n) => n < 5), "lastMatching<5");
testOp((i) => i.lastMatching((n) => n < 10), "lastMatching<10");
testOp((i) => i.singleMatching((n) => n < 5), "singelMatching<5");
testOp((i) => i.singleMatching((n) => n < 10), "singelMatching<10");
testOp((i) => i.firstWhere((n) => n < 5), "firstWhere<5");
testOp((i) => i.firstWhere((n) => n < 10), "firstWhere<10");
testOp((i) => i.lastWhere((n) => n < 5), "lastWhere<5");
testOp((i) => i.lastWhere((n) => n < 10), "lastWhere<10");
testOp((i) => i.singleWhere((n) => n < 5), "singelWhere<5");
testOp((i) => i.singleWhere((n) => n < 10), "singelWhere<10");
testOp((i) => i.contains(5), "contains(5)");
testOp((i) => i.contains(10), "contains(10)");
testOp((i) => i.any((n) => n < 5), "any<5");

View file

@ -230,10 +230,10 @@ abstract class QueueTest {
queue.retainAll([1, 3, 5, 7, 9, 10]); // Remove 2 and 8.
testLength(17, queue);
queue.removeMatching((x) => x == 7);
queue.removeWhere((x) => x == 7);
testLength(14, queue);
queue.retainMatching((x) => x != 3);
queue.retainWhere((x) => x != 3);
testLength(11, queue);
Expect.listEquals([9, 1, 5, 9, 10, 1, 5, 9, 10, 1, 5], queue.toList());
@ -346,11 +346,11 @@ class ListQueueTest extends QueueTest {
Expect.equals(255, q.length);
// Remove element at end of internal buffer.
q.removeMatching((v) => v == 255);
q.removeWhere((v) => v == 255);
// Remove element at beginning of internal buffer.
q.removeMatching((v) => v == 0);
q.removeWhere((v) => v == 0);
// Remove element at both ends of internal buffer.
q.removeMatching((v) => v == 254 || v == 1);
q.removeWhere((v) => v == 254 || v == 1);
Expect.equals(251, q.length);

View file

@ -267,16 +267,16 @@ main() {
stream.single.then((_) {});
});
test('firstMatching', () {
stream.firstMatching((_) => true).then((_) {});
test('firstWhere', () {
stream.firstWhere((_) => true).then((_) {});
});
test('lastMatching', () {
stream.lastMatching((_) => true).then((_) {});
test('lastWhere', () {
stream.lastWhere((_) => true).then((_) {});
});
test('singleMatching', () {
stream.singleMatching((_) => true).then((_) {});
test('singleWhere', () {
stream.singleWhere((_) => true).then((_) {});
});
test('elementAt', () {

View file

@ -24,7 +24,7 @@ main() {
'buffer': buffer
}, '*', [buffer]);
return window.onMessage.firstMatching(
return window.onMessage.firstWhere(
(e) {
return e.data is Map && e.data['id'] == 'transferable data';
}).then((messageEvent) {

View file

@ -156,59 +156,59 @@ testSingleController() {
testExtraMethods() {
Events sentEvents = new Events()..add(7)..add(9)..add(13)..add(87)..close();
test("firstMatching", () {
test("firstWhere", () {
StreamController c = new StreamController();
Future f = c.stream.firstMatching((x) => (x % 3) == 0);
Future f = c.stream.firstWhere((x) => (x % 3) == 0);
f.then(expectAsync1((v) { Expect.equals(9, v); }));
sentEvents.replay(c);
});
test("firstMatching 2", () {
test("firstWhere 2", () {
StreamController c = new StreamController();
Future f = c.stream.firstMatching((x) => (x % 4) == 0);
Future f = c.stream.firstWhere((x) => (x % 4) == 0);
f.catchError(expectAsync1((e) {}));
sentEvents.replay(c);
});
test("firstMatching 3", () {
test("firstWhere 3", () {
StreamController c = new StreamController();
Future f = c.stream.firstMatching((x) => (x % 4) == 0, defaultValue: () => 999);
Future f = c.stream.firstWhere((x) => (x % 4) == 0, defaultValue: () => 999);
f.then(expectAsync1((v) { Expect.equals(999, v); }));
sentEvents.replay(c);
});
test("lastMatching", () {
test("lastWhere", () {
StreamController c = new StreamController();
Future f = c.stream.lastMatching((x) => (x % 3) == 0);
Future f = c.stream.lastWhere((x) => (x % 3) == 0);
f.then(expectAsync1((v) { Expect.equals(87, v); }));
sentEvents.replay(c);
});
test("lastMatching 2", () {
test("lastWhere 2", () {
StreamController c = new StreamController();
Future f = c.stream.lastMatching((x) => (x % 4) == 0);
Future f = c.stream.lastWhere((x) => (x % 4) == 0);
f.catchError(expectAsync1((e) {}));
sentEvents.replay(c);
});
test("lastMatching 3", () {
test("lastWhere 3", () {
StreamController c = new StreamController();
Future f = c.stream.lastMatching((x) => (x % 4) == 0, defaultValue: () => 999);
Future f = c.stream.lastWhere((x) => (x % 4) == 0, defaultValue: () => 999);
f.then(expectAsync1((v) { Expect.equals(999, v); }));
sentEvents.replay(c);
});
test("singleMatching", () {
test("singleWhere", () {
StreamController c = new StreamController();
Future f = c.stream.singleMatching((x) => (x % 9) == 0);
Future f = c.stream.singleWhere((x) => (x % 9) == 0);
f.then(expectAsync1((v) { Expect.equals(9, v); }));
sentEvents.replay(c);
});
test("singleMatching 2", () {
test("singleWhere 2", () {
StreamController c = new StreamController();
Future f = c.stream.singleMatching((x) => (x % 3) == 0); // Matches both 9 and 87..
Future f = c.stream.singleWhere((x) => (x % 3) == 0); // Matches both 9 and 87..
f.catchError(expectAsync1((e) { Expect.isTrue(e.error is StateError); }));
sentEvents.replay(c);
});

View file

@ -94,12 +94,12 @@ abstract class CssClassSet implements Set<String> {
_modify((s) => s.retainAll(iterable));
}
void removeMatching(bool test(String name)) {
_modify((s) => s.removeMatching(test));
void removeWhere(bool test(String name)) {
_modify((s) => s.removeWhere(test));
}
void retainMatching(bool test(String name)) {
_modify((s) => s.retainMatching(test));
void retainWhere(bool test(String name)) {
_modify((s) => s.retainWhere(test));
}
bool isSubsetOf(Collection<String> collection) =>
@ -127,12 +127,12 @@ abstract class CssClassSet implements Set<String> {
Iterable<String> skip(int n) => readClasses().skip(n);
Iterable<String> skipWhile(bool test(String value)) =>
readClasses().skipWhile(test);
String firstMatching(bool test(String value), { String orElse() }) =>
readClasses().firstMatching(test, orElse: orElse);
String lastMatching(bool test(String value), {String orElse()}) =>
readClasses().lastMatching(test, orElse: orElse);
String singleMatching(bool test(String value)) =>
readClasses().singleMatching(test);
String firstWhere(bool test(String value), { String orElse() }) =>
readClasses().firstWhere(test, orElse: orElse);
String lastWhere(bool test(String value), {String orElse()}) =>
readClasses().lastWhere(test, orElse: orElse);
String singleWhere(bool test(String value)) =>
readClasses().singleWhere(test);
String elementAt(int index) => readClasses().elementAt(index);
void clear() {

View file

@ -63,13 +63,13 @@ class _WrappedList<E> implements List<E> {
E get single => _list.single;
E firstMatching(bool test(E value), { E orElse() }) =>
_list.firstMatching(test, orElse: orElse);
E firstWhere(bool test(E value), { E orElse() }) =>
_list.firstWhere(test, orElse: orElse);
E lastMatching(bool test(E value), {E orElse()}) =>
_list.lastMatching(test, orElse: orElse);
E lastWhere(bool test(E value), {E orElse()}) =>
_list.lastWhere(test, orElse: orElse);
E singleMatching(bool test(E value)) => _list.singleMatching(test);
E singleWhere(bool test(E value)) => _list.singleWhere(test);
E elementAt(int index) => _list.elementAt(index);
@ -85,9 +85,9 @@ class _WrappedList<E> implements List<E> {
void retainAll(Iterable elements) { _list.retainAll(elements); }
void removeMatching(bool test(E element)) { _list.removeMatching(test); }
void removeWhere(bool test(E element)) { _list.removeWhere(test); }
void retainMatching(bool test(E element)) { _list.retainMatching(test); }
void retainWhere(bool test(E element)) { _list.retainWhere(test); }
void clear() { _list.clear(); }

View file

@ -99,16 +99,16 @@ class _ChildrenElementList implements List {
return IterableMixinWorkaround.skipWhile(this, test);
}
Element firstMatching(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Element firstWhere(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Element lastMatching(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Element lastWhere(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Element singleMatching(bool test(Element value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Element singleWhere(bool test(Element value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Element elementAt(int index) {
@ -185,12 +185,12 @@ class _ChildrenElementList implements List {
IterableMixinWorkaround.retainAll(this, elements);
}
void removeMatching(bool test(Element element)) {
IterableMixinWorkaround.removeMatching(this, test);
void removeWhere(bool test(Element element)) {
IterableMixinWorkaround.removeWhere(this, test);
}
void retainMatching(bool test(Element element)) {
IterableMixinWorkaround.retainMatching(this, test);
void retainWhere(bool test(Element element)) {
IterableMixinWorkaround.retainWhere(this, test);
}
void removeRange(int start, int rangeLength) {
@ -342,16 +342,16 @@ class _FrozenElementList implements List {
return IterableMixinWorkaround.skipWhile(this, test);
}
Element firstMatching(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Element firstWhere(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Element lastMatching(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Element lastWhere(bool test(Element value), {Element orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Element singleMatching(bool test(Element value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Element singleWhere(bool test(Element value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Element elementAt(int index) {
@ -444,11 +444,11 @@ class _FrozenElementList implements List {
throw new UnsupportedError('');
}
void removeMatching(bool test(Element element)) {
void removeWhere(bool test(Element element)) {
throw new UnsupportedError('');
}
void retainMatching(bool test(Element element)) {
void retainWhere(bool test(Element element)) {
throw new UnsupportedError('');
}

View file

@ -115,12 +115,12 @@ $endif
IterableMixinWorkaround.retainAll(this, elements);
}
void removeMatching(bool test(Node node)) {
IterableMixinWorkaround.removeMatching(this, test);
void removeWhere(bool test(Node node)) {
IterableMixinWorkaround.removeWhere(this, test);
}
void retainMatching(bool test(Node node)) {
IterableMixinWorkaround.retainMatching(this, test);
void retainWhere(bool test(Node node)) {
IterableMixinWorkaround.retainWhere(this, test);
}
void clear() {
@ -188,16 +188,16 @@ $endif
return IterableMixinWorkaround.skipWhile(this, test);
}
Node firstMatching(bool test(Node value), {Node orElse()}) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
Node firstWhere(bool test(Node value), {Node orElse()}) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
Node lastMatching(bool test(Node value), {Node orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
Node lastWhere(bool test(Node value), {Node orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
Node singleMatching(bool test(Node value)) {
return IterableMixinWorkaround.singleMatching(this, test);
Node singleWhere(bool test(Node value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
Node elementAt(int index) {

View file

@ -61,16 +61,16 @@ $endif
return IterableMixinWorkaround.skipWhile(this, test);
}
$E firstMatching(bool test($E value), { $E orElse() }) {
return IterableMixinWorkaround.firstMatching(this, test, orElse);
$E firstWhere(bool test($E value), { $E orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
$E lastMatching(bool test($E value), {$E orElse()}) {
return IterableMixinWorkaround.lastMatchingInList(this, test, orElse);
$E lastWhere(bool test($E value), {$E orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
$E singleMatching(bool test($E value)) {
return IterableMixinWorkaround.singleMatching(this, test);
$E singleWhere(bool test($E value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
$E elementAt(int index) {
@ -164,11 +164,11 @@ $endif
throw new UnsupportedError("Cannot remove from immutable List.");
}
void removeMatching(bool test($E element)) {
void removeWhere(bool test($E element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
void retainMatching(bool test($E element)) {
void retainWhere(bool test($E element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}

View file

@ -331,7 +331,7 @@ class ArgParser {
* that abbreviation.
*/
Option findByAbbreviation(String abbr) {
return options.values.firstMatching((option) => option.abbreviation == abbr,
return options.values.firstWhere((option) => option.abbreviation == abbr,
orElse: () => null);
}
}

View file

@ -4,7 +4,7 @@ import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
/// Returns the metadata for the given string or null if not found.
InstanceMirror findMetadata(List<InstanceMirror> metadataList, String find) {
return metadataList.firstMatching(
return metadataList.firstWhere(
(metadata) {
if (metadata is TypeInstanceMirror) {
return metadata.representedType.simpleName == find;