areImmutableCollectionsWithEqualItems function
Will return true
only if the collections are of the same type, and their
items are equal by calling the collection's equalItems
method. This may be
slow for very large collection, since it compares each item, one by one.
Note this will not compare the collection configuration.
Implementation
bool areImmutableCollectionsWithEqualItems(ImmutableCollection? c1, ImmutableCollection? c2) {
if (identical(c1, c2)) return true;
if (c1 is IList && c2 is IList) return (c1).equalItems(c2);
if (c1 is ISet && c2 is ISet) return (c1).equalItems(c2);
if (c1 is IMap && c2 is IMap) return (c1).equalItemsToIMap(c2);
if (c1 is IMapOfSets && c2 is IMapOfSets) return (c1).equalItemsToIMapOfSets(c2);
return false;
}