Cytoscape 2.8.0 API

cytoscape.util.intr
Class IntHash

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

public final class IntHash
extends Object
implements Serializable

An insert-only hashtable that has non-negative 32 bit integer keys; no satellite data is stored in this hashtable. An instance of this class is well-suited for efficiently detecting collisions between integers, removing duplicates from a list of integers, or determining the presence of an integer in a list of integers.

In the underlying implementation, this hashtable increases in size to adapt to elements 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 elements in a perfectly-sized array. Underlying size expansions are implemented such that the operation of expanding in size is amortized over the contstant time complexity of inserting 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.

See Also:
Serialized Form

Constructor Summary
IntHash()
          Creates a new hashtable.
 
Method Summary
 IntEnumerator elements()
          Returns an enumeration of elements in this hashtable, ordered arbitrarily.
 void empty()
          Removes all elements from this hashtable.
 int get(int value)
          Determines whether or not the value specified is in this hashtable.
 int put(int value)
          Puts a new value into this hashtable if that value is not already in this hashtable; otherwise does nothing.
 int size()
          Returns the number of elements currently in this hashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntHash

public IntHash()
Creates a new hashtable.

Method Detail

empty

public final void empty()
Removes all elements from this hashtable. This operation has O(1) time complexity.


size

public final int size()
Returns the number of elements currently in this hashtable.


put

public final int put(int value)
Puts a new value into this hashtable if that value is not already in this hashtable; otherwise does nothing. Returns the input value if this value was already in this hashtable; returns -1 if the input value was not in this hashtable prior to this call.

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

Throws:
IllegalArgumentException - if value is negative.

get

public final int get(int value)
Determines whether or not the value specified is in this hashtable. Returns the value specified if this value is in the hashtable, otherwise returns -1.

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

Throws:
IllegalArgumentException - if value is negative.

elements

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

The returned enumeration becomes invalid as soon as put(int) or empty() 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 elements in [amortized] time complexity O(1).


Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.