Cytoscape 2.6.2 (c) 2006,2007 ISB, MSKCC, UCSD

cytoscape.util.intr
Class IntObjHash

java.lang.Object
  extended by cytoscape.util.intr.IntObjHash
All Implemented Interfaces:
Serializable

public final class IntObjHash
extends Object
implements Serializable

An insert-only hashtable that has non-negative 32 bit integer keys and non-null object values.

In the underlying implementation, this hashtable increases in size to adapt to key/value pairs being added (the underlying size of the hashtable is invisible to the programmer). In the underlying implementation, this hashtable never decreases in size. As a hashtable increases in size, it takes at most four times as much memory as it would take to store the hashtable's keys and values in perfectly-sized arrays. Underlying size expansions are implemented such that the operation of expanding in size is amortized over the contstant time complexity needed to insert new elements.

An instance of this class is serializable; however, serialized instances of this class should not be stored in a persistent manner because the serialization implemented in this class makes no attempt at handling class versioning. For an instance of this class to be properly serialized, all object values stored in that instance must be serializable.

See Also:
Serialized Form

Constructor Summary
IntObjHash()
          Creates a new hashtable.
 
Method Summary
 Object get(int key)
          Returns the value bound to the specified key or null if no value is currently bound to the specified key.
 IntEnumerator keys()
          Returns an enumeration of keys in this hashtable, ordered arbitrarily.
static int maxCapacity(int num)
          For a hashtable that currently holds exactly num keys [or zero keys if num is negative], returns the maximum number of keys that that hashtable can hold without undergoing an underlying size expansion.
 Object put(int key, Object value)
          Puts a new key/value pair into this hashtable, potentially overwriting an existing value whose key is the same as the one specified.
 int size()
          Returns the number of key/value pairs currently in this hashtable.
 Iterator values()
          Returns an iteration of values in this hashtable, ordered arbitrarily.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntObjHash

public IntObjHash()
Creates a new hashtable.

Method Detail

maxCapacity

public static final int maxCapacity(int num)
For a hashtable that currently holds exactly num keys [or zero keys if num is negative], returns the maximum number of keys that that hashtable can hold without undergoing an underlying size expansion. Size expansions are expensive computationally and result in a doubling of the amount of memory consumed; this function is a hook for users of hashtables to do smart things when an underlying size expansion is about to happen. Returns -1 if a hashtable cannot hold the number of keys specified (num too large for algorithms to work).


size

public final int size()
Returns the number of key/value pairs currently in this hashtable.


put

public final Object put(int key,
                        Object value)
Puts a new key/value pair into this hashtable, potentially overwriting an existing value whose key is the same as the one specified. Returns the old value associated with the specified key or null if no value is associated with specified key at the time of this call.

Insertions into the hashtable are performed in [amortized] time complexity O(1).

Throws:
IllegalArgumentException - if key is negative.
NullPointerException - if value is null.

get

public final Object get(int key)
Returns the value bound to the specified key or null if no value is currently bound to the specified key.

Searches in this hashtable are performed in [amortized] time complexity O(1).

Throws:
IllegalArgumentException - if key is negative.

keys

public final IntEnumerator keys()
Returns an enumeration of keys in this hashtable, ordered arbitrarily.

The returned enumeration becomes invalid as soon as put(int, Object) is called on this hashtable; calling methods on an invalid enumeration will cause undefined behavior in the enumerator. The returned enumerator has absolutely no effect on the underlying hashtable.

This method returns in constant time. The returned enumerator returns successive keys in [amortized] time complexity O(1).


values

public final Iterator values()
Returns an iteration of values in this hashtable, ordered arbitrarily.

The returned iteration becomes invalid as soon as put(int, Object) is called on this hashtable; calling methods on an invalid iteration will cause undefined behavior in the iterator. The returned iterator has absolutely no effect on the underlying hashtable (the remove() operation on the returned iterator is not supported).

This method returns in constant time. The returned iterator returns successive values in [amortized] time complexity O(1).

NOTE: The order of values returned corresponds to the order of keys returned by the enumeration from keys() - that is, the nth key returned by keys() is the key into the nth value returned by values().


www.cytoscape.org