contentEquals method

bool contentEquals(
  1. Iterable<E> other, [
  2. bool checkEqual(
    1. E a,
    2. E b
    )?
])

Returns true if this collection is structurally equal to the other collection.

I.e. contain the same number of the same elements in the same order.

If checkEqual is provided, it is used to check if two elements are the same.

Implementation

bool contentEquals(Iterable<E> other, [bool Function(E a, E b)? checkEqual]) {
  var it1 = iterator;
  var it2 = other.iterator;
  if (checkEqual != null) {
    while (it1.moveNext()) {
      if (!it2.moveNext()) return false;
      if (!checkEqual(it1.current, it2.current)) return false;
    }
  } else {
    while (it1.moveNext()) {
      if (!it2.moveNext()) return false;
      if (it1.current != it2.current) return false;
    }
  }
  return !it2.moveNext();
}