Class UnionSetView<E>

  • Type Parameters:
    E - the elements
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

    public final class UnionSetView<E>
    extends AbstractUnmodifiableSet<E>
    Author:
    Mathias Hofer
    • Constructor Summary

      Constructors 
      Constructor Description
      UnionSetView​(java.util.Set<E> set1, java.util.Set<E> set2)
      Expects the two sets to be disjoint, otherwise some methods, e.g.
    • Method Summary

      Modifier and Type Method Description
      boolean contains​(java.lang.Object o)  
      boolean containsAll​(java.util.Collection<?> c)  
      boolean isEmpty()  
      java.util.Iterator<E> iterator()  
      static <E> java.util.Set<E> of​(java.util.Set<E> set1, java.util.Set<E> set2, java.util.Set<E> set3)  
      int size()  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      • Methods inherited from class java.util.AbstractSet

        equals, hashCode
      • Methods inherited from class java.util.AbstractCollection

        toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        spliterator
    • Constructor Detail

      • UnionSetView

        public UnionSetView​(java.util.Set<E> set1,
                            java.util.Set<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 Detail

      • of

        public static <E> java.util.Set<E> of​(java.util.Set<E> set1,
                                              java.util.Set<E> set2,
                                              java.util.Set<E> set3)
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.Set<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.Set<E>
        Overrides:
        isEmpty in class java.util.AbstractCollection<E>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.Set<E>
        Overrides:
        contains in class java.util.AbstractCollection<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.Set<E>
        Specified by:
        iterator in class java.util.AbstractCollection<E>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.Set<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.Set<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface java.util.Set<E>
        Overrides:
        containsAll in class java.util.AbstractCollection<E>