public final class MapBackedSet<E,V> extends Objectimplements 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
|
void |
clear()
|
boolean |
contains(Object
|
boolean |
containsAll(Collection
|
boolean |
equals(Object
|
int |
hashCode()
|
boolean |
isEmpty()
|
Iterator |
iterator()
|
static <E |
mapBackedSet(Map
Factory method to create a set from a map.
|
static <E |
mapBackedSet(Map
Factory method to create a set from a map.
|
boolean |
remove(Object
|
boolean |
removeAll(Collection
|
boolean |
retainAll(Collection
|
int |
size()
|
Object |
toArray()
|
<T> T[] |
toArray(T[] array)
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitspliteratorparallelStream, removeIf, streampublic static <E,V> MapBackedSet <E ,V> mapBackedSet(Map <E ,? super V> map)
E - the element type
V - the dummy value type in the map
map - the map to decorate, must not be null
NullPointerException - if map is null
public static <E,V> MapBackedSet <E ,V> mapBackedSet(Map <E ,? super V> map, V dummyValue)
E - the element type
V - the dummy value type in the map
map - the map to decorate, must not be null
dummyValue - the dummy value to use
NullPointerException - if map is null
public int size()
public boolean isEmpty()
public boolean contains(Objectobj)
public boolean containsAll(Collection<?> coll)
public boolean add(E obj)
public boolean addAll(Collection<? extends E> coll)
public boolean remove(Objectobj)
public boolean removeAll(Collection<?> coll)
public boolean retainAll(Collection<?> coll)
public void clear()
public Object[] toArray()
public <T> T[] toArray(T[] array)
public boolean equals(Objectobj)
public int hashCode()