Class MinusSetView<E>

  • All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

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

      Constructors 
      Constructor Description
      MinusSetView​(java.util.Set<E> superset, java.util.Set<E> subset)
      Constructs a view of the result of superset - subset.
    • 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()  
      int size()  
      • Methods inherited from class java.util.AbstractSet

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

        toArray, toArray, 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, toArray, toArray
    • Constructor Detail

      • MinusSetView

        public MinusSetView​(java.util.Set<E> superset,
                            java.util.Set<E> subset)
        Constructs a view of the result of superset - subset.

        As the name suggests, it is expected that all elements of subset are contained in superset, otherwise one has to expect unreasonable results.

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

        Parameters:
        superset - the minuend
        subset - the subtrahend
    • Method Detail

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