Class MapBackedSet
- java.lang.Object
-
- org.apache.commons.collections.set.MapBackedSet
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable,java.util.Collection,java.util.Set
public final class MapBackedSet extends java.lang.Object implements java.util.Set, java.io.SerializableDecorates 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
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object obj)booleanaddAll(java.util.Collection coll)voidclear()booleancontains(java.lang.Object obj)booleancontainsAll(java.util.Collection coll)static java.util.Setdecorate(java.util.Map map)Factory method to create a set from a map.static java.util.Setdecorate(java.util.Map map, java.lang.Object dummyValue)Factory method to create a set from a map.booleanequals(java.lang.Object obj)inthashCode()booleanisEmpty()java.util.Iteratoriterator()booleanremove(java.lang.Object obj)booleanremoveAll(java.util.Collection coll)booleanretainAll(java.util.Collection coll)intsize()java.lang.Object[]toArray()java.lang.Object[]toArray(java.lang.Object[] array)
-
-
-
Method Detail
-
decorate
public static java.util.Set decorate(java.util.Map map)
Factory method to create a set from a map.- Parameters:
map- the map to decorate, must not be null- Throws:
java.lang.IllegalArgumentException- if set is null
-
decorate
public static java.util.Set decorate(java.util.Map map, java.lang.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:
java.lang.IllegalArgumentException- if map is null
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection- Specified by:
sizein interfacejava.util.Set
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection- Specified by:
isEmptyin interfacejava.util.Set
-
iterator
public java.util.Iterator iterator()
- Specified by:
iteratorin interfacejava.util.Collection- Specified by:
iteratorin interfacejava.lang.Iterable- Specified by:
iteratorin interfacejava.util.Set
-
contains
public boolean contains(java.lang.Object obj)
- Specified by:
containsin interfacejava.util.Collection- Specified by:
containsin interfacejava.util.Set
-
containsAll
public boolean containsAll(java.util.Collection coll)
- Specified by:
containsAllin interfacejava.util.Collection- Specified by:
containsAllin interfacejava.util.Set
-
add
public boolean add(java.lang.Object obj)
- Specified by:
addin interfacejava.util.Collection- Specified by:
addin interfacejava.util.Set
-
addAll
public boolean addAll(java.util.Collection coll)
- Specified by:
addAllin interfacejava.util.Collection- Specified by:
addAllin interfacejava.util.Set
-
remove
public boolean remove(java.lang.Object obj)
- Specified by:
removein interfacejava.util.Collection- Specified by:
removein interfacejava.util.Set
-
removeAll
public boolean removeAll(java.util.Collection coll)
- Specified by:
removeAllin interfacejava.util.Collection- Specified by:
removeAllin interfacejava.util.Set
-
retainAll
public boolean retainAll(java.util.Collection coll)
- Specified by:
retainAllin interfacejava.util.Collection- Specified by:
retainAllin interfacejava.util.Set
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection- Specified by:
clearin interfacejava.util.Set
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.Set
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] array)
- Specified by:
toArrayin interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.Set
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfacejava.util.Collection- Specified by:
equalsin interfacejava.util.Set- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection- Specified by:
hashCodein interfacejava.util.Set- Overrides:
hashCodein classjava.lang.Object
-
-