goodslib
Class Htree

java.lang.Object
  extended bygoodsjpi.Persistent
      extended bygoodslib.Htree
All Implemented Interfaces:
java.io.Serializable

public class Htree
extends Persistent

H-Tree: combination of tree and hash table

See Also:
Serialized Form

Field Summary
 
Fields inherited from class goodsjpi.Persistent
defaultMetaobject, metaobject
 
Constructor Summary
Htree()
          Constructs a new, empty Htree with the default hash size (1000003) and default page size (128)
Htree(int hashSize)
          Constructs a new, empty Htree with the specified hash size and default page size (128)
Htree(int hashSize, int pageBits)
          Constructs a new, empty Htree with the specified size and logarithm of page size (number of bits from the key used as page index)
 
Method Summary
 void clear()
          Clears this Htree so that it contains no keys.
 Persistent get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this Htree
 Persistent put(Persistent key, Persistent value)
          Maps the specified key to the specified value in this Htree.
 Persistent put(java.lang.String key, Persistent value)
          Associate object with string key.
 Persistent remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this Htree.
 int size()
          Returns the number of keys in this Htree.
 
Methods inherited from class goodsjpi.Persistent
attachToStorage, clone, clusterWith, finalize, getDatabase, getOid, getStorageId, hashCode, onLoad
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Htree

public Htree(int hashSize,
             int pageBits)
Constructs a new, empty Htree with the specified size and logarithm of page size (number of bits from the key used as page index)

Parameters:
hashSize - hash key divider
pageBits - logarithm of page size

Htree

public Htree(int hashSize)
Constructs a new, empty Htree with the specified hash size and default page size (128)

Parameters:
hashSize - hash key divider

Htree

public Htree()
Constructs a new, empty Htree with the default hash size (1000003) and default page size (128)

Method Detail

size

public int size()
Returns the number of keys in this Htree.

Returns:
the number of keys in this Htree.

get

public Persistent get(java.lang.Object key)
Returns the value to which the specified key is mapped in this Htree

Parameters:
key - a key in the Htree.
Returns:
the value to which the key is mapped in this Htree; null if the key is not mapped to any value in this Htree.

put

public Persistent put(Persistent key,
                      Persistent value)
Maps the specified key to the specified value in this Htree. Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - the Htree key.
value - the value.
Returns:
the previous value of the specified key in this Htree, or null if it did not have one.

put

public Persistent put(java.lang.String key,
                      Persistent value)
Associate object with string key.


remove

public Persistent remove(java.lang.Object key)
Removes the key (and its corresponding value) from this Htree. This method does nothing if the key is not in the Htree.

Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this Htree, or null if the key did not have a mapping.

clear

public void clear()
Clears this Htree so that it contains no keys.