Framework Professional Edition Package


com.prosyst.util.hash
Class HashLongObjNS

java.lang.Object
  extended by com.prosyst.util.hash.HashLongObjNS
Direct Known Subclasses:
HashLongObjS

public class HashLongObjNS
extends java.lang.Object

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


Field Summary
 long[] 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
HashLongObjNS()
          Constructs an empty hash table with keys of type long and values af type int.
HashLongObjNS(HashLongObjNS source)
           
HashLongObjNS(int capacity)
          Constructs an empty hash table with keys of type long and values af type int.
HashLongObjNS(int capacity, double lf)
          Constructs an empty hash table with keys of type long and values of type int.
 
Method Summary
 java.lang.Object get(long key)
          Returns an value which is mapped to the key key.
 void put(long key, java.lang.Object value)
          Adds in 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(long 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 long[] 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

HashLongObjNS

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


HashLongObjNS

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

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

HashLongObjNS

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

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

HashLongObjNS

public HashLongObjNS(HashLongObjNS source)
Method Detail

put

public void put(long key,
                java.lang.Object value)
Adds in 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(long 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(long 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