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 TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> coll) void
clear()
boolean
boolean
containsAll
(Collection<?> coll) boolean
int
hashCode()
boolean
isEmpty()
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
boolean
removeAll
(Collection<?> coll) boolean
boolean
retainAll
(Collection<?> coll) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] array) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream
Methods 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:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
equals
-
hashCode
-
isEmpty
-
iterator
-
remove
-
removeAll
-
removeIf
- Specified by:
removeIf
in interfaceCollection<E>
- Since:
- 4.4
-
retainAll
-
size
-
toArray
-
toArray
-