Class UnmodifiableUnionSet<E>

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

    public class UnmodifiableUnionSet<E>
    extends java.util.AbstractSet<E>
    implements java.io.Serializable
    An unmodifiable live view of the union of two sets.
    Author:
    Dimitrios Michail
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      UnmodifiableUnionSet​(java.util.Set<E> first, java.util.Set<E> second)
      Constructs a new set.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(java.lang.Object o)  
      java.util.Iterator<E> iterator()  
      int size()
      Since the view is live, this operation is no longer a constant time operation.
      • Methods inherited from class java.util.AbstractSet

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

        add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

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

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

        forEach
      • Methods inherited from interface java.util.Set

        add, addAll, clear, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
    • Constructor Detail

      • UnmodifiableUnionSet

        public UnmodifiableUnionSet​(java.util.Set<E> first,
                                    java.util.Set<E> second)
        Constructs a new set.
        Parameters:
        first - the first set
        second - the second set
    • Method Detail

      • 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>
      • size

        public int size()
        Since the view is live, this operation is no longer a constant time operation.
        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>
      • 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>