matches method
Returns true
if this
and other
are the same length and
contain all of the same elements.
If ordered
is true
, the elements must be in the same order
in both iterables for this to return true
.
Implementation
bool matches(Iterable<T> other, {bool ordered = false}) {
if (length != other.length) {
return false;
}
if (ordered) {
for (var i = 0; i < length; i++) {
if (elementAt(i) != other.elementAt(i)) {
return false;
}
}
} else {
final elements = toList();
for (var element in other) {
if (!elements.remove(element)) {
return false;
}
}
}
return true;
}