org.apache.commons.collections.set

Class MapBackedSet

public final class MapBackedSet extends Object implements Set, Serializable

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: 357494 $ $Date: 2005-12-18 19:05:31 +0000 (Sun, 18 Dec 2005) $

Author: Stephen Colebourne

Field Summary
protected ObjectdummyValue
The dummyValue to use
protected Mapmap
The map being used as the backing store
Method Summary
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)

Field Detail

dummyValue

protected final Object dummyValue
The dummyValue to use

map

protected final Map map
The map being used as the backing store

Method Detail

add

public boolean add(Object obj)

addAll

public boolean addAll(Collection coll)

clear

public void clear()

contains

public boolean contains(Object obj)

containsAll

public boolean containsAll(Collection coll)

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 null dummyValue the dummy value to use

Throws: IllegalArgumentException if map is null

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

isEmpty

public boolean isEmpty()

iterator

public Iterator iterator()

remove

public boolean remove(Object obj)

removeAll

public boolean removeAll(Collection coll)

retainAll

public boolean retainAll(Collection coll)

size

public int size()

toArray

public Object[] toArray()

toArray

public Object[] toArray(Object[] array)
Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.