unionE method

Enumerable<T> unionE (Iterable<T> other, { EqualityComparer<T> comparer })

Returns the set union between the enumerable and the given collection.

After applying the unionE method to an enumerable, the resulting enumerable will consist of all the distinct elements in the source enumerable as well as the distinct elements in the given other collection. This is equivalent to taking the set union of the two sequences.

Optionally, an EqualityComparer can be supplied to handle comparisons. If one is provided, the unionE method will use the comparer and hasher properties in order to determine equivalency. If omitted, unionE will resort to strict equivalency (i.e. checking if (value == element)).

(For the unionE method, only the comparer and hasher properties of the EqualityComparer need be supplied.)

Due to the nature of set unions, the resulting enumerable will be as though distinctE was applied to it, so duplicate elements after the first found will be discarded. If the intention is to combine elements of two enumerables/collections, use concatE instead.

Implementation

Enumerable<T> unionE(Iterable<T> other, {EqualityComparer<T> comparer}) {
  assert(other != null);
  return UnionEnumerable<T>(this, other, comparer);
}