Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Util.Collections
Class SimpleHashSet  view SimpleHashSet download SimpleHashSet.java

java.lang.Object
  extended byjava.util.AbstractMap
      extended byUtil.Collections.SimpleHashSet
All Implemented Interfaces:
java.util.Map

public class SimpleHashSet
extends java.util.AbstractMap

Version:
$Id: SimpleHashSet.java,v 1.3 2003/07/07 10:32:22 joewhaley Exp $

Nested Class Summary
static class SimpleHashSet.ChainSet
           
static class SimpleHashSet.Entry
           
 class SimpleHashSet.EntrySet
           
 class SimpleHashSet.SetView
           
 
Nested classes inherited from class java.util.AbstractMap
 
Field Summary
 int[][] chains
           
 int size
           
static int STARTING_CHAIN_SIZE
           
static int STARTING_HASH_SIZE
           
static int STARTING_TABLE_SIZE
           
 java.lang.Object[] table
           
static boolean TRACE
           
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
SimpleHashSet()
           
 
Method Summary
 boolean add(java.lang.Object o)
           
private  int addToTable_helper(java.lang.Object b, int hash, int[] chain, int index)
           
 boolean contains(java.lang.Object arg0)
           
 boolean containsAll(java.util.Collection c)
           
 boolean containsKey(java.lang.Object arg0)
          Returns true if this contains a mapping for the given key.
 boolean containsValue(java.lang.Object arg0)
          Returns true if this contains at least one mapping with the given value.
 java.util.Set entrySet()
          Returns a set view of the mappings in this Map.
 java.lang.Object get(java.lang.Object o)
          Returns the value mapped by the given key.
 java.util.Set getAsSet()
           
 int getID(java.lang.Object b)
           
 java.util.Set getMatchingHashcode(int hash)
           
 java.lang.Object getOrAdd(java.lang.Object o)
           
 int getOrAddID(java.lang.Object b)
           
private  void growTable_helper()
           
 java.util.Iterator iterator()
           
 java.util.Set keySet()
          Returns a set view of this map's keys.
 java.lang.Object put(java.lang.Object arg0, java.lang.Object arg1)
          Associates the given key to the given value (optional operation).
 void putAll(java.util.Map arg0)
          Copies all entries of the given map to this one (optional operation).
 int size()
          Returns the number of key-value mappings in the map.
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 java.util.Collection values()
          Returns a collection or bag view of this map's values.
 
Methods inherited from class java.util.AbstractMap
clear, clone, equals, hashCode, isEmpty, remove, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TRACE

public static final boolean TRACE
See Also:
Constant Field Values

STARTING_TABLE_SIZE

public static final int STARTING_TABLE_SIZE
See Also:
Constant Field Values

STARTING_HASH_SIZE

public static final int STARTING_HASH_SIZE
See Also:
Constant Field Values

STARTING_CHAIN_SIZE

public static final int STARTING_CHAIN_SIZE
See Also:
Constant Field Values

table

public java.lang.Object[] table

size

public int size

chains

public int[][] chains
Constructor Detail

SimpleHashSet

public SimpleHashSet()
Method Detail

iterator

public java.util.Iterator iterator()

size

public int size()
Description copied from class: java.util.AbstractMap
Returns the number of key-value mappings in the map. If there are more than Integer.MAX_VALUE mappings, return Integer.MAX_VALUE. This is implemented as entrySet().size().


add

public boolean add(java.lang.Object o)

getMatchingHashcode

public java.util.Set getMatchingHashcode(int hash)

getOrAdd

public java.lang.Object getOrAdd(java.lang.Object o)

get

public java.lang.Object get(java.lang.Object o)
Description copied from class: java.util.AbstractMap
Returns the value mapped by the given key. Returns null if there is no mapping. However, in Maps that accept null values, you must rely on containsKey to determine if a mapping exists. This iteration takes linear time, searching entrySet().iterator() of the key. Many implementations override this method.


getID

public int getID(java.lang.Object b)

getOrAddID

public int getOrAddID(java.lang.Object b)

addToTable_helper

private int addToTable_helper(java.lang.Object b,
                              int hash,
                              int[] chain,
                              int index)

growTable_helper

private void growTable_helper()

contains

public boolean contains(java.lang.Object arg0)

containsKey

public boolean containsKey(java.lang.Object arg0)
Description copied from class: java.util.AbstractMap
Returns true if this contains a mapping for the given key. This implementation does a linear search, O(n), over the entrySet(), returning true if a match is found, false if the iteration ends. Many subclasses can implement this more efficiently.


containsValue

public boolean containsValue(java.lang.Object arg0)
Description copied from class: java.util.AbstractMap
Returns true if this contains at least one mapping with the given value. This implementation does a linear search, O(n), over the entrySet(), returning true if a match is found, false if the iteration ends. A match is defined as a value, v, where (value == null ? v == null : value.equals(v)). Subclasses are unlikely to implement this more efficiently.


entrySet

public java.util.Set entrySet()
Description copied from class: java.util.AbstractMap
Returns a set view of the mappings in this Map. Each element in the set must be an implementation of Map.Entry. The set is backed by the map, so that changes in one show up in the other. Modifications made while an iterator is in progress cause undefined behavior. If the set supports removal, these methods must be valid: Iterator.remove, Set.remove, removeAll, retainAll, and clear. Element addition is not supported via this set.


containsAll

public boolean containsAll(java.util.Collection c)

toArray

public java.lang.Object[] toArray()

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)

getAsSet

public java.util.Set getAsSet()

keySet

public java.util.Set keySet()
Description copied from class: java.util.AbstractMap
Returns a set view of this map's keys. The set is backed by the map, so changes in one show up in the other. Modifications while an iteration is in progress produce undefined behavior. The set supports removal if entrySet() does, but does not support element addition.

This implementation creates an AbstractSet, where the iterator wraps the entrySet iterator, size defers to the Map's size, and contains defers to the Map's containsKey. The set is created on first use, and returned on subsequent uses, although since no synchronization occurs, there is a slight possibility of creating two sets.


put

public java.lang.Object put(java.lang.Object arg0,
                            java.lang.Object arg1)
Description copied from class: java.util.AbstractMap
Associates the given key to the given value (optional operation). If the map already contains the key, its value is replaced. This implementation simply throws an UnsupportedOperationException. Be aware that in a map that permits null values, a null return does not always imply that the mapping was created.


putAll

public void putAll(java.util.Map arg0)
Description copied from class: java.util.AbstractMap
Copies all entries of the given map to this one (optional operation). If the map already contains a key, its value is replaced. This implementation simply iterates over the map's entrySet(), calling put, so it is not supported if puts are not.


values

public java.util.Collection values()
Description copied from class: java.util.AbstractMap
Returns a collection or bag view of this map's values. The collection is backed by the map, so changes in one show up in the other. Modifications while an iteration is in progress produce undefined behavior. The collection supports removal if entrySet() does, but does not support element addition.

This implementation creates an AbstractCollection, where the iterator wraps the entrySet iterator, size defers to the Map's size, and contains defers to the Map's containsValue. The collection is created on first use, and returned on subsequent uses, although since no synchronization occurs, there is a slight possibility of creating two collections.