Class MapBackedSet
java.lang.Object
org.apache.commons.collections.set.MapBackedSet
- All Implemented Interfaces:
Serializable,Iterable,Collection,Set
Decorates a
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.
- Since:
- Commons Collections 3.1
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- Author:
- Stephen Colebourne
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection coll) voidclear()booleanbooleancontainsAll(Collection coll) static SetFactory method to create a set from a map.static SetFactory method to create a set from a map.booleaninthashCode()booleanisEmpty()iterator()booleanbooleanremoveAll(Collection coll) booleanretainAll(Collection coll) intsize()Object[]toArray()Object[]Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator
-
Field Details
-
map
The map being used as the backing store -
dummyValue
The dummyValue to use
-
-
Method Details
-
decorate
Factory method to create a set from a map.- Parameters:
map- the map to decorate, must not be null- Throws:
IllegalArgumentException- if set is null
-
decorate
Factory method to create a set from a map.- Parameters:
map- the map to decorate, must not be nulldummyValue- the dummy value to use- Throws:
IllegalArgumentException- if map is null
-
size
public int size()- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceSet
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceSet
-
iterator
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceSet
-
containsAll
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceSet
-
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceSet
-
addAll
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceSet
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceSet
-
removeAll
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceSet
-
retainAll
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceSet
-
clear
public void clear()- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceSet
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
equals
-
hashCode
public int hashCode()
-