public abstract static class Sets.SetView<E> extends AbstractSet<E>
SetView
; typically,
you either use it as a plain Set
, or immediately invoke immutableCopy()
or
copyInto(S)
and forget the SetView
itself.Modifier and Type | Method and Description |
---|---|
boolean |
add(E e)
Deprecated.
Unsupported operation.
|
boolean |
addAll(Collection<? extends E> newElements)
Deprecated.
Unsupported operation.
|
void |
clear()
Deprecated.
Unsupported operation.
|
<S extends Set<E>> |
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 |
remove(Object object)
Deprecated.
Unsupported operation.
|
boolean |
removeAll(Collection<?> oldElements)
Deprecated.
Unsupported operation.
|
boolean |
removeIf(Predicate<? super E> filter)
Deprecated.
Unsupported operation.
|
boolean |
retainAll(Collection<?> elementsToKeep)
Deprecated.
Unsupported operation.
|
equals, hashCode
contains, containsAll, isEmpty, size, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
contains, containsAll, isEmpty, size, spliterator, toArray, toArray
parallelStream, stream
public ImmutableSet<E> immutableCopy()
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 TreeSet
using a comparator
that is inconsistent with Object.equals(Object)
.
@CanIgnoreReturnValue public <S extends Set<E>> S copyInto(S set)
set.addAll(this)
, assuming that all the sets involved are based on the
same notion of equivalence.set
, for convenience@CanIgnoreReturnValue @Deprecated public final boolean add(E e)
add
in interface Collection<E>
add
in interface Set<E>
add
in class AbstractCollection<E>
e
- element whose presence in this collection is to be ensuredUnsupportedOperationException
- always@CanIgnoreReturnValue @Deprecated public final boolean remove(Object object)
remove
in interface Collection<E>
remove
in interface Set<E>
remove
in class AbstractCollection<E>
object
- element to be removed from this collection, if presentUnsupportedOperationException
- always@CanIgnoreReturnValue @Deprecated public final boolean addAll(Collection<? extends E> newElements)
addAll
in interface Collection<E>
addAll
in interface Set<E>
addAll
in class AbstractCollection<E>
newElements
- collection containing elements to be added to this collectionUnsupportedOperationException
- alwaysAbstractCollection.add(Object)
@CanIgnoreReturnValue @Deprecated public final boolean removeAll(Collection<?> oldElements)
removeAll
in interface Collection<E>
removeAll
in interface Set<E>
removeAll
in class AbstractSet<E>
oldElements
- collection containing elements to be removed from this setUnsupportedOperationException
- alwaysAbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
@CanIgnoreReturnValue @Deprecated public final boolean removeIf(Predicate<? super E> filter)
filter
- a predicate which returns true
for elements to be
removedtrue
if any elements were removedUnsupportedOperationException
- always@CanIgnoreReturnValue @Deprecated public final boolean retainAll(Collection<?> elementsToKeep)
retainAll
in interface Collection<E>
retainAll
in interface Set<E>
retainAll
in class AbstractCollection<E>
elementsToKeep
- collection containing elements to be retained in this collectionUnsupportedOperationException
- alwaysAbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
@Deprecated public final void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
UnsupportedOperationException
- alwayspublic abstract UnmodifiableIterator<E> iterator()
UnmodifiableIterator
to ensure this is an unmodifiable view.iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in interface Set<E>
iterator
in class AbstractCollection<E>
Iterator
since 2.0)Copyright © 2010–2018. All rights reserved.