## org.apache.commons.collections.set
Class MapBackedSet

    java.lang.Object
      org.apache.commons.collections.set.MapBackedSet

All Implemented Interfaces:
  Collection, Serializable, Set

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: 1.2 $ $Date: 2004/06/02 22:00:47 $
Author:
  Stephen Colebourne
See Also:
  Serialized Form

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)`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### map

    protected final Map map

  The map being used as the backing store

### dummyValue

    protected final Object dummyValue

  The dummyValue to use

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 null
    `dummyValue` - the dummy value to use
  Throws:
    `IllegalArgumentException` - if map is null

### size

    public int size()

  Specified by:
    `size` in interface `Set`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `Set`

### iterator

    public Iterator iterator()

  Specified by:
    `iterator` in interface `Set`

### contains

    public boolean contains(Object obj)

  Specified by:
    `contains` in interface `Set`

### containsAll

    public boolean containsAll(Collection coll)

  Specified by:
    `containsAll` in interface `Set`

### add

    public boolean add(Object obj)

  Specified by:
    `add` in interface `Set`

### addAll

    public boolean addAll(Collection coll)

  Specified by:
    `addAll` in interface `Set`

### remove

    public boolean remove(Object obj)

  Specified by:
    `remove` in interface `Set`

### removeAll

    public boolean removeAll(Collection coll)

  Specified by:
    `removeAll` in interface `Set`

### retainAll

    public boolean retainAll(Collection coll)

  Specified by:
    `retainAll` in interface `Set`

### clear

    public void clear()

  Specified by:
    `clear` in interface `Set`

### toArray

    public Object[] toArray()

  Specified by:
    `toArray` in interface `Set`

### toArray

    public Object[] toArray(Object[] array)

  Specified by:
    `toArray` in interface `Set`

### equals

    public boolean equals(Object obj)

  Specified by:
    `equals` in interface `Set`

### hashCode

    public int hashCode()

  Specified by:
    `hashCode` in interface `Set`

Copyright © 2001-2005 Apache Software Foundation. All Rights Reserved.