isEqualsSet<T> function

bool isEqualsSet<T>(
  1. Set<T>? s1,
  2. Set<T>? s2
)

Returns true if both sets, s1 and s2, have equals entries in the same order.

Implementation

bool isEqualsSet<T>(Set<T>? s1, Set<T>? s2) {
  if (identical(s1, s2)) return true;
  if (s1 == null) return false;
  if (s2 == null) return false;

  var length = s1.length;
  if (length != s2.length) return false;

  var itr1 = s1.iterator;
  var itr2 = s2.iterator;

  while (itr1.moveNext()) {
    if (!itr2.moveNext()) {
      return false;
    }

    var v1 = itr1.current;
    var v2 = itr2.current;

    if (v1 != v2) return false;
  }

  return true;
}