Class SetUtils.SetView<E>

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

    public abstract static class SetUtils.SetView<E>
    extends java.util.AbstractSet<E>
    An unmodifiable view of a set that may be backed by other sets.

    If the decorated sets change, this view will change as well. The contents of this view can be transferred to another instance via the copyInto(Set) and toSet() methods.

    Since:
    4.1
    • Constructor Summary

      Constructors 
      Constructor Description
      SetView()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <S extends java.util.Set<E>>
      void
      copyInto​(S set)
      Copies the contents of this view into the provided set.
      java.util.Iterator<E> iterator()  
      int size()  
      java.util.Set<E> toSet()
      Returns a new set containing the contents of this view.
      • Methods inherited from class java.util.AbstractSet

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

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

        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, contains, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
    • Constructor Detail

      • SetView

        public SetView()
    • Method Detail

      • copyInto

        public <S extends java.util.Set<E>> void copyInto​(S set)
        Copies the contents of this view into the provided set.
        Type Parameters:
        S - the set type
        Parameters:
        set - the set for copying the contents
      • 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()
        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>
      • toSet

        public java.util.Set<E> toSet()
        Returns a new set containing the contents of this view.
        Returns:
        a new set containing all elements of this view