Package com.google.common.collect
Class Sets.SetView<E>
-
- <E>
-
- <E>
-
- com.google.common.collect.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 typeSetView
; typically, you either use it as a plain , or immediately invokeimmutableCopy()
orcopyInto(S)
and forget theSetView
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>>
ScopyInto(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 toUnmodifiableIterator
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.
-
-
-
Method Detail
-
immutableCopy
public ImmutableSet<E> immutableCopy()
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 toset.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.
-
remove
public final boolean object)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
addAll
public final boolean <? extends E> newElements)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
removeAll
public final boolean <?> oldElements)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
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 returnstrue
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.
-
clear
public final void clear()
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
iterator
public abstract UnmodifiableIterator<E> iterator()
Scope the return type toUnmodifiableIterator
to ensure this is an unmodifiable view.
-
-