Class MinusSetView<E>

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

    public final class MinusSetView<E>
    extends AbstractUnmodifiableCollection<E>
    implements java.util.Set<E>
    Mathias Hofer
    • Constructor Summary

      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()  
      static <E> java.util.Set<E> of​(java.util.Set<E> superset, E subtrahend)  
      int size()  
      • Methods inherited from class java.util.AbstractCollection

        toArray, toArray, toString
      • Methods inherited from class java.lang.Object

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

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

      • Methods inherited from interface java.util.Set

        add, addAll, clear, equals, hashCode, remove, removeAll, retainAll, 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.

        superset - the minuend
        subset - the subtrahend
    • Method Detail

      • of

        public static <E> java.util.Set<E> of​(java.util.Set<E> superset,
                                              E subtrahend)
      • 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>
        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>
        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>
        containsAll in class java.util.AbstractCollection<E>