Class MapBackedSet
- java.lang.Object
-
- org.apache.commons.collections.set.MapBackedSet
-
- All Implemented Interfaces:
Serializable,Iterable,Collection,Set
public final class MapBackedSet extends Object implements Set, Serializable
Decorates aMapto obtainSetbehaviour.This class is used to create a
Setwith the same properties as the key set of any map. Thus, a ReferenceSet can be created by wrapping aReferenceMapin an instance of this class.Most map implementation can be used to create a set by passing in dummy values. Exceptions include
BidiMapimplementations, 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ObjectdummyValueThe dummyValue to useprotected MapmapThe map being used as the backing store
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Object obj)booleanaddAll(Collection coll)voidclear()booleancontains(Object obj)booleancontainsAll(Collection coll)static Setdecorate(Map map)Factory method to create a set from a map.static Setdecorate(Map map, Object dummyValue)Factory method to create a set from a map.booleanequals(Object obj)inthashCode()booleanisEmpty()Iteratoriterator()booleanremove(Object obj)booleanremoveAll(Collection coll)booleanretainAll(Collection coll)intsize()Object[]toArray()Object[]toArray(Object[] 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, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Method Detail
-
decorate
public static Set decorate(Map map)
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
public static Set decorate(Map map, Object dummyValue)
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
public Iterator iterator()
-
contains
public boolean contains(Object obj)
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceSet
-
containsAll
public boolean containsAll(Collection coll)
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceSet
-
add
public boolean add(Object obj)
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceSet
-
addAll
public boolean addAll(Collection coll)
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceSet
-
remove
public boolean remove(Object obj)
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceSet
-
removeAll
public boolean removeAll(Collection coll)
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceSet
-
retainAll
public boolean retainAll(Collection coll)
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceSet
-
clear
public void clear()
- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceSet
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
toArray
public Object[] toArray(Object[] array)
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
equals
public boolean equals(Object obj)
-
-