Class UnionSetView<E>

Type Parameters:
E - the type of elements in this set
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public final class UnionSetView<E> extends AbstractUnmodifiableCollection<E> implements Set<E>
A view that provides the union of two disjoint sets as a single set. This class does not copy the elements from the sets but merely wraps them. It is expected that the two sets are disjoint, as methods like size() assume that there is no overlap between the elements.

This class provides an unmodifiable view and all modification operations will throw UnsupportedOperationException.

Author:
Mathias Hofer
  • Constructor Details

    • UnionSetView

      public UnionSetView(Set<? extends E> set1, Set<? extends E> set2)
      Expects the two sets to be disjoint, otherwise some methods, e.g. size(), will return unreasonable results.

      It is up to the caller to ensure this property, this class performs no additional checks.

      Parameters:
      set1 - the first set
      set2 - the second set
  • Method Details