weka.classifiers.lazy.kstar
Class KStarCache.CacheTable

java.lang.Object
  extended byweka.classifiers.lazy.kstar.KStarCache.CacheTable
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
KStarCache

public class KStarCache.CacheTable
extends java.lang.Object
implements java.io.Serializable

A custom hashtable class to support the caching system.

See Also:
Serialized Form

Field Summary
private  float DEFAULT_LOAD_FACTOR
          The default load factor for the hashtable
private  int DEFAULT_TABLE_SIZE
          The default size of the hashtable
private  double EPSILON
          Accuracy value for equality
private  int m_Count
          The total number of entries in the hash table.
private  float m_LoadFactor
          The load factor for the hashtable.
private  KStarCache.TableEntry[] m_Table
          The hash table data.
private  int m_Threshold
          Rehashes the table when count exceeds this threshold.
 
Constructor Summary
KStarCache.CacheTable()
          Constructs a new hashtable with a default capacity and load factor.
KStarCache.CacheTable(int size, float loadFactor)
          Constructs a new hashtable with a default capacity and load factor.
 
Method Summary
 void clear()
          Clears this hashtable so that it contains no keys.
 boolean containsKey(double key)
          Tests if the specified double is a key in this hashtable.
 KStarCache.TableEntry getEntry(double key)
          Returns the table entry to which the specified key is mapped in this hashtable.
private  int hashCode(double key)
          Returns the hash code of the specified double.
 void insert(double key, double value, double pmiss)
          Inserts a new entry in the hashtable using the specified key.
 boolean isEmpty()
          Tests if this hashtable maps no keys to values.
private  void rehash()
          Rehashes the contents of the hashtable into a hashtable with a larger capacity.
 int size()
          Returns the number of keys in this hashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Table

private KStarCache.TableEntry[] m_Table
The hash table data.


m_Count

private int m_Count
The total number of entries in the hash table.


m_Threshold

private int m_Threshold
Rehashes the table when count exceeds this threshold.


m_LoadFactor

private float m_LoadFactor
The load factor for the hashtable.


DEFAULT_TABLE_SIZE

private final int DEFAULT_TABLE_SIZE
The default size of the hashtable

See Also:
Constant Field Values

DEFAULT_LOAD_FACTOR

private final float DEFAULT_LOAD_FACTOR
The default load factor for the hashtable

See Also:
Constant Field Values

EPSILON

private final double EPSILON
Accuracy value for equality

See Also:
Constant Field Values
Constructor Detail

KStarCache.CacheTable

public KStarCache.CacheTable(int size,
                             float loadFactor)
Constructs a new hashtable with a default capacity and load factor.


KStarCache.CacheTable

public KStarCache.CacheTable()
Constructs a new hashtable with a default capacity and load factor.

Method Detail

containsKey

public boolean containsKey(double key)
Tests if the specified double is a key in this hashtable.


insert

public void insert(double key,
                   double value,
                   double pmiss)
Inserts a new entry in the hashtable using the specified key. If the key already exist in the hashtable, do nothing.


getEntry

public KStarCache.TableEntry getEntry(double key)
Returns the table entry to which the specified key is mapped in this hashtable.

Returns:
a table entry.

size

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

Returns:
the number of keys in this hashtable.

isEmpty

public boolean isEmpty()
Tests if this hashtable maps no keys to values.

Returns:
true if this hastable maps no keys to values.

clear

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


rehash

private 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.


hashCode

private int hashCode(double key)
Returns the hash code of the specified double.

Returns:
the hash code of the specified double.