Class Sets.SetView<E>

  • All Implemented Interfaces:
    <E>, <E>, <E>
    Enclosing class:
    Sets

    public abstract static class Sets.SetView<E>
    extends <E>
    An unmodifiable view of a set which may be backed by other sets; this view will change as the backing sets do. Contains methods to copy the data into a new set which will then remain stable. There is usually no reason to retain a reference of type SetView; typically, you either use it as a plain , or immediately invoke immutableCopy() or copyInto(S) and forget the SetView itself.
    Since:
    2.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean add​(E e)
      Deprecated.
      Unsupported operation.
      boolean <? extends E> newElements)
      Deprecated.
      Unsupported operation.
      void clear()
      Deprecated.
      Unsupported operation.
      <S extends <E>>
      S
      copyInto​(S set)
      Copies the current contents of this set view into an existing set.
      ImmutableSet<E> immutableCopy()
      Returns an immutable copy of the current contents of this set view.
      abstract UnmodifiableIterator<E> iterator()
      Scope the return type to UnmodifiableIterator to ensure this is an unmodifiable view.
      boolean  object)
      Deprecated.
      Unsupported operation.
      boolean <?> oldElements)
      Deprecated.
      Unsupported operation.
      boolean <? super E> filter)
      Deprecated.
      Unsupported operation.
      boolean <?> elementsToKeep)
      Deprecated.
      Unsupported operation.
      • Methods inherited from class java.util.

        ,
      • Methods inherited from class java.util.

        , , , , , ,
      • Methods inherited from class java.lang.

        , , , , , , ,
      • Methods inherited from interface java.util.

        , ,
      • Methods inherited from interface java.lang.

      • Methods inherited from interface java.util.

        , , , , , ,
    • Method Detail

      • immutableCopy

        public ImmutableSet<EimmutableCopy()
        Returns an immutable copy of the current contents of this set view. Does not support null elements.

        Warning: this may have unexpected results if a backing set of this view uses a nonstandard notion of equivalence, for example if it is a using a comparator that is inconsistent with .

      • copyInto

        public <S extends <E>> S copyInto​(S set)
        Copies the current contents of this set view into an existing set. This method has equivalent behavior to set.addAll(this), assuming that all the sets involved are based on the same notion of equivalence.
        Returns:
        a reference to set, for convenience
      • add

        
        public final boolean add​(E e)
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the collection unmodified.
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Overrides:
         in class <E>
        Parameters:
        e - element whose presence in this collection is to be ensured
        Returns:
        true if this collection changed as a result of the call
        Throws:
        - always
      • remove

        
        public final boolean  object)
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the collection unmodified.
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Overrides:
         in class <E>
        Parameters:
        object - element to be removed from this collection, if present
        Returns:
        true if an element was removed as a result of this call
        Throws:
        - always
      • addAll

        
        public final boolean <? extends E> newElements)
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the collection unmodified.
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Overrides:
         in class <E>
        Parameters:
        newElements - collection containing elements to be added to this collection
        Returns:
        true if this collection changed as a result of the call
        Throws:
        - always
        See Also:
      • removeAll

        
        public final boolean <?> oldElements)
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the collection unmodified.
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Overrides:
         in class <E>
        Parameters:
        oldElements - collection containing elements to be removed from this set
        Returns:
        true if this set changed as a result of the call
        Throws:
        - always
        See Also:
        ,
      • removeIf

        
        public final boolean <? super E> filter)
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the collection unmodified.
        Parameters:
        filter - a predicate which returns true for elements to be removed
        Returns:
        true if any elements were removed
        Throws:
        - always
      • retainAll

        
        public final boolean <?> elementsToKeep)
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the collection unmodified.
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Overrides:
         in class <E>
        Parameters:
        elementsToKeep - collection containing elements to be retained in this collection
        Returns:
        true if this collection changed as a result of the call
        Throws:
        - always
        See Also:
        ,
      • clear

        public final void clear()
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the collection unmodified.
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Overrides:
         in class <E>
        Throws:
        - always
      • iterator

        public abstract UnmodifiableIterator<Eiterator()
        Scope the return type to UnmodifiableIterator to ensure this is an unmodifiable view.
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Specified by:
         in interface <E>
        Specified by:
         in class <E>
        Returns:
        an iterator over the elements contained in this collection
        Since:
        20.0 (present with return type since 2.0)