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 TypeMethodDescriptionboolean
boolean
addAll
(Collection coll) void
clear()
boolean
boolean
containsAll
(Collection coll) static Set
Factory method to create a set from a map.static Set
Factory method to create a set from a map.boolean
int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection coll) boolean
retainAll
(Collection coll) int
size()
Object[]
toArray()
Object[]
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods 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:
size
in interfaceCollection
- Specified by:
size
in interfaceSet
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection
- Specified by:
isEmpty
in interfaceSet
-
iterator
-
contains
- Specified by:
contains
in interfaceCollection
- Specified by:
contains
in interfaceSet
-
containsAll
- Specified by:
containsAll
in interfaceCollection
- Specified by:
containsAll
in interfaceSet
-
add
- Specified by:
add
in interfaceCollection
- Specified by:
add
in interfaceSet
-
addAll
- Specified by:
addAll
in interfaceCollection
- Specified by:
addAll
in interfaceSet
-
remove
- Specified by:
remove
in interfaceCollection
- Specified by:
remove
in interfaceSet
-
removeAll
- Specified by:
removeAll
in interfaceCollection
- Specified by:
removeAll
in interfaceSet
-
retainAll
- Specified by:
retainAll
in interfaceCollection
- Specified by:
retainAll
in interfaceSet
-
clear
public void clear()- Specified by:
clear
in interfaceCollection
- Specified by:
clear
in interfaceSet
-
toArray
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceSet
-
toArray
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceSet
-
equals
-
hashCode
public int hashCode()
-