setEquals<T> function

bool setEquals<T>(
  1. Iterable<T>? it1,
  2. Iterable<T>? it2
)

Returns true if all the elemnts in iterable1 are contained in iterable2. Assumes there are no dupes in either iterable.

Implementation

bool setEquals<T>(Iterable<T>? it1, Iterable<T>? it2) {
  if (it1 == null || it2 == null) {
    return false;
  }
  if (it1.length != it2.length) {
    return false;
  }
  for (final a in it1) {
    if (!it2.contains(a)) {
      return false;
    }
  }
  return true;
}