E
- the type of the elements in this setV
- the dummy value type in this mappublic final class MapBackedSet<E,V> extends Object implements Set<E>, Serializable
Map
to obtain Set
behaviour.
This class is used to create a Set
with the same properties as
the key set of any map. Thus, a ReferenceSet can be created by wrapping a
ReferenceMap
in an instance of this class.
Most map implementation can be used to create a set by passing in dummy values.
Exceptions include BidiMap
implementations, as they require unique values.
Modifier and Type | Method and Description |
---|---|
boolean |
add(E obj) |
boolean |
addAll(Collection<? extends E> coll) |
void |
clear() |
boolean |
contains(Object obj) |
boolean |
containsAll(Collection<?> coll) |
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
static <E,V> MapBackedSet<E,V> |
mapBackedSet(Map<E,? super V> map)
Factory method to create a set from a map.
|
static <E,V> MapBackedSet<E,V> |
mapBackedSet(Map<E,? super V> map,
V dummyValue)
Factory method to create a set from a map.
|
boolean |
remove(Object obj) |
boolean |
removeAll(Collection<?> coll) |
boolean |
removeIf(Predicate<? super E> filter) |
boolean |
retainAll(Collection<?> coll) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] array) |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
spliterator
parallelStream, stream
public static <E,V> MapBackedSet<E,V> mapBackedSet(Map<E,? super V> map)
E
- the element typeV
- the dummy value type in the mapmap
- the map to decorate, must not be nullNullPointerException
- if map is nullpublic static <E,V> MapBackedSet<E,V> mapBackedSet(Map<E,? super V> map, V dummyValue)
E
- the element typeV
- the dummy value type in the mapmap
- the map to decorate, must not be nulldummyValue
- the dummy value to useNullPointerException
- if map is nullpublic int size()
public boolean isEmpty()
public boolean containsAll(Collection<?> coll)
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
public boolean addAll(Collection<? extends E> coll)
public boolean removeIf(Predicate<? super E> filter)
removeIf
in interface Collection<E>
public boolean removeAll(Collection<?> coll)
public boolean retainAll(Collection<?> coll)
public void clear()
public <T> T[] toArray(T[] array)
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.