Class MapBackedSet<E,V>
java.lang.Object
org.apache.commons.collections4.set.MapBackedSet<E,V>
- Type Parameters:
E- the type of the elements in this setV- the dummy value type in this map
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Set<E>
Decorates a
Map to obtain Set behavior.
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.
- Since:
- 3.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> coll) voidclear()booleanbooleancontainsAll(Collection<?> coll) booleaninthashCode()booleanisEmpty()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.booleanbooleanremoveAll(Collection<?> coll) booleanbooleanretainAll(Collection<?> coll) intsize()Object[]toArray()<T> T[]toArray(T[] array) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, streamMethods inherited from interface java.util.Set
spliterator
-
Method Details
-
mapBackedSet
Factory method to create a set from a map.- Type Parameters:
E- the element typeV- the dummy value type in the map- Parameters:
map- the map to decorate, must not be null- Returns:
- a new map backed set
- Throws:
NullPointerException- if map is null- Since:
- 4.0
-
mapBackedSet
Factory method to create a set from a map.- Type Parameters:
E- the element typeV- the dummy value type in the map- Parameters:
map- the map to decorate, must not be nulldummyValue- the dummy value to use- Returns:
- a new map backed set
- Throws:
NullPointerException- if map is null- Since:
- 4.0
-
add
-
addAll
-
clear
-
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>
-
equals
-
hashCode
-
isEmpty
-
iterator
-
remove
-
removeAll
-
removeIf
-
retainAll
-
size
-
toArray
-
toArray
-