Framework Professional Edition Package


com.prosyst.util.hash
Class HashIntObjNS

java.lang.Object
  extended by com.prosyst.util.hash.HashIntObjNS
Direct Known Subclasses:
HashIntObjS

public class HashIntObjNS
extends java.lang.Object

Hashtable for mapping int keys to Object values. The methods of this hashtable are not synchronized, and if used concurently must be externally synchronized


Field Summary
 int[] keys
          Used to enumerate the keys in the hash table.
 int[] next
          Can be used to check if a key or value is valid.
 java.lang.Object[] values
          Used to enumerate the values in the hash table.
 
Constructor Summary
HashIntObjNS()
          Constructs an empty hash table with keys of type int and values af type Object.
HashIntObjNS(int capacity)
          Constructs an empty hash table with keys of type int and values af type Object.
HashIntObjNS(int capacity, double lf)
          Constructs an empty hash table with keys of type int and values of type Object.
 
Method Summary
 java.lang.Object get(int key)
          Returns an value which is mapped to the key key.
 void put(int key, java.lang.Object value)
          Adds in the hashtable an element with key key and value value.
 void rehash()
          Rehashes the contents of the hashtable into a hashtable with a larger capacity.
 java.lang.Object remove(int key)
          Removes an element with the specified key from the table.
 void removeAll()
          Empties the hash table
 int size()
          Returns the count of elements currently in the table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keys

public int[] keys
Used to enumerate the keys in the hash table. The key at index i is valid only if


values

public java.lang.Object[] values
Used to enumerate the values in the hash table. The value at index i is valid only if


next

public int[] next
Can be used to check if a key or value is valid. The value or key at index i is valid if the following expression is true

Constructor Detail

HashIntObjNS

public HashIntObjNS()
Constructs an empty hash table with keys of type int and values af type Object. Uses default load factor (0.75) and default capacity (89)


HashIntObjNS

public HashIntObjNS(int capacity)
Constructs an empty hash table with keys of type int and values af type Object. Uses default load factor (0.75).

Parameters:
capacity - initial capacity of the table
Throws:
java.lang.IllegalArgumentException - if capacity < 1.

HashIntObjNS

public HashIntObjNS(int capacity,
                    double lf)
Constructs an empty hash table with keys of type int and values of type Object.

Parameters:
capacity - initial capacity of the table
lf - load factor ot the table
Throws:
java.lang.IllegalArgumentException - if capacity < 1 or lf < 0.0
Method Detail

put

public void put(int key,
                java.lang.Object value)
Adds in the hashtable an element with key key and value value. If an element with the specified key is already in the table only change it's value.

Parameters:
key - the key of the inserted element
value - the value of the inserted element

get

public java.lang.Object get(int key)
Returns an value which is mapped to the key key.

Parameters:
key - the key we are searching for
Returns:
the value this key is mapped to in the table, or null

remove

public java.lang.Object remove(int key)
Removes an element with the specified key from the table. Does nothing if there is no element with this key.

Parameters:
key - the key of the element we want to remove
Returns:
the removed value, or null if there was nothing to remove

removeAll

public void removeAll()
Empties the hash table


rehash

public void rehash()
Rehashes the contents of the hashtable into a hashtable with a larger capacity. This method is called automatically when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.


size

public int size()
Returns the count of elements currently in the table

Returns:
the count of elements

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved