union method
Returns a new lazy Iterable containing all distinct elements from both collections.
The returned set preserves the element iteration order of this collection.
Those elements of the other
collection that are unique are iterated in
the end in the order of the other
collection.
Implementation
Iterable<E> union(Iterable<E> other) sync* {
final existing = HashSet<E>();
for (final element in this) {
if (existing.add(element)) yield element;
}
for (final element in other) {
if (existing.add(element)) yield element;
}
}