org.h2.util
Class HashBase

java.lang.Object
  extended by org.h2.util.HashBase
Direct Known Subclasses:
IntIntHashMap, ValueHashMap

public abstract class HashBase
extends java.lang.Object

The base for other hash classes.


Field Summary
protected  int deletedCount
          The number of deleted slots.
protected  int len
          The number of slots in the table.
protected  int level
          The level.
protected  int mask
          The bit mask to get the index from the hash code.
protected  int size
          The number of occupied slots, excluding the zero key (if any).
protected  boolean zeroKey
          Whether the zero key is used.
 
Constructor Summary
HashBase()
           
 
Method Summary
protected  void checkSizeRemove()
          Check the size before removing an entry.
protected  int getIndex(int hash)
          Calculate the index for this hash code.
protected abstract  void rehash(int newLevel)
          Increase the size of the underlying table and re-distribute the elements.
protected  void reset(int newLevel)
          Clear the map and reset the level to the specified value.
 int size()
          Get the size of the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mask

protected int mask
The bit mask to get the index from the hash code.


len

protected int len
The number of slots in the table.


size

protected int size
The number of occupied slots, excluding the zero key (if any).


deletedCount

protected int deletedCount
The number of deleted slots.


level

protected int level
The level. The number of slots is 2 ^ level.


zeroKey

protected boolean zeroKey
Whether the zero key is used.

Constructor Detail

HashBase

public HashBase()
Method Detail

rehash

protected abstract void rehash(int newLevel)
Increase the size of the underlying table and re-distribute the elements.

Parameters:
newLevel - the new level

size

public int size()
Get the size of the map.

Returns:
the size

checkSizeRemove

protected void checkSizeRemove()
Check the size before removing an entry. This method resizes the map if required.


reset

protected void reset(int newLevel)
Clear the map and reset the level to the specified value.

Parameters:
newLevel - the new level

getIndex

protected int getIndex(int hash)
Calculate the index for this hash code.

Parameters:
hash - the hash code
Returns:
the index