com.go.trove.util
Class MapBackedSet

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractSet
              |
              +--com.go.trove.util.MapBackedSet
All Implemented Interfaces:
java.util.Collection, java.io.Serializable, java.util.Set
Direct Known Subclasses:
UsageSet

public class MapBackedSet
extends java.util.AbstractSet
implements java.io.Serializable

A set implementation that is backed by any map.

Version:
12 , 9/07/00
Author:
Brian S O'Neill
See Also:
Serialized Form

Field Summary
protected  java.util.Map mMap
           
 
Constructor Summary
MapBackedSet(java.util.Map map)
           
 
Method Summary
 boolean add(java.lang.Object obj)
          Adds the specified element to this set if it is not already present.
 void clear()
          Removes all of the elements from this set.
 boolean contains(java.lang.Object obj)
          Returns true if this set contains the specified element.
 boolean isEmpty()
          Returns true if this set contains no elements.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this set.
 boolean remove(java.lang.Object obj)
          Removes the given element from this set if it is present.
 int size()
          Returns the number of elements in this set (its cardinality).
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, toArray, toArray
 

Field Detail

mMap

protected final java.util.Map mMap
Constructor Detail

MapBackedSet

public MapBackedSet(java.util.Map map)
Parameters:
map - The map to back this set.
Method Detail

iterator

public java.util.Iterator iterator()
Returns an iterator over the elements in this set. The elements are returned in the order determined by the backing map.
Overrides:
iterator in class java.util.AbstractCollection
Returns:
an Iterator over the elements in this set.
See Also:
ConcurrentModificationException

size

public int size()
Returns the number of elements in this set (its cardinality).
Overrides:
size in class java.util.AbstractCollection
Returns:
the number of elements in this set (its cardinality).

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.
Overrides:
isEmpty in class java.util.AbstractCollection
Returns:
true if this set contains no elements.

contains

public boolean contains(java.lang.Object obj)
Returns true if this set contains the specified element.
Overrides:
contains in class java.util.AbstractCollection
Returns:
true if this set contains the specified element.

add

public boolean add(java.lang.Object obj)
Adds the specified element to this set if it is not already present.
Overrides:
add in class java.util.AbstractCollection
Parameters:
obj - element to be added to this set.
Returns:
true if the set did not already contain the specified element.

remove

public boolean remove(java.lang.Object obj)
Removes the given element from this set if it is present.
Overrides:
remove in class java.util.AbstractCollection
Parameters:
obj - object to be removed from this set, if present.
Returns:
true if the set contained the specified element.

clear

public void clear()
Removes all of the elements from this set.
Overrides:
clear in class java.util.AbstractCollection