org.apache.commons.collections.set

Class MapBackedSet

Implemented Interfaces:
Serializable, Set

public final class MapBackedSet
extends java.lang.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.

Version:
$Revision: 1.2 $ $Date: 2004/06/02 22:00:47 $
Author:
Stephen Colebourne
Since:
Commons Collections 3.1

Field Summary

protected Object
dummyValue
The dummyValue to use
protected Map
map
The map being used as the backing store

Method Summary

boolean
add(Object obj)
boolean
addAll(Collection coll)
void
clear()
boolean
contains(Object obj)
boolean
containsAll(Collection coll)
static Set
decorate(Map map)
Factory method to create a set from a map.
static Set
decorate(Map map, Object dummyValue)
Factory method to create a set from a map.
boolean
equals(Object obj)
int
hashCode()
boolean
isEmpty()
Iterator
iterator()
boolean
remove(Object obj)
boolean
removeAll(Collection coll)
boolean
retainAll(Collection coll)
int
size()
Object[]
toArray()
Object[]
toArray(Object[] array)

Field Details

dummyValue

protected final Object dummyValue
The dummyValue to use

map

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

Method Details

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

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

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-2006 Apache Software Foundation. All Rights Reserved.