shared
Class InstanceHashTable
java.lang.Object
|
+--shared.InstanceHashTable
- public class InstanceHashTable
- extends java.lang.Object
InstanceHashTable is a clean interface to the user of hash table of
instances. This HashTable handles collisions by placing the colliding instances
in an InstanceList at that position in the HashTable.
Because the hashCode function does not gaurantee distinct values, it is
possible for colliding instances to not be equivalent.
|
Constructor Summary |
InstanceHashTable(int estimatedNum)
Constructor with estimated number of instances in the hash table and
an InstanceList. |
InstanceHashTable(int estimatedNum,
InstanceList ihl)
Constructor with estimated number of instances in the hash table and
an InstanceList. |
|
Method Summary |
InstanceList |
find(Instance instance)
Returns the reference to the InstanceList matching the given Instance. |
void |
insert(Instance instance)
Adds an instance into the hash table by converting the instance into a
InstanceListSameAttr of the one instance. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
InstanceHashTable
public InstanceHashTable(int estimatedNum)
- Constructor with estimated number of instances in the hash table and
an InstanceList. If a non-null InstanceList is given, all the instance in
the InstanceList will be inserted into the hash table.
- Parameters:
estimatedNum - The estimated number of Instances.
InstanceHashTable
public InstanceHashTable(int estimatedNum,
InstanceList ihl)
- Constructor with estimated number of instances in the hash table and
an InstanceList. If a non-null InstanceList is given, all the instance in
the InstanceList will be inserted into the hash table.
- Parameters:
estimatedNum - The estimated number of Instances.ihl - The InstanceList of Instances to place in this
InstanceHashTable.
find
public InstanceList find(Instance instance)
- Returns the reference to the InstanceList matching the given Instance.
- Parameters:
instance - The Instance used as a key in this Hashtable.- Returns:
- An InstanceList if found or NULL if there is no such element.
insert
public void insert(Instance instance)
- Adds an instance into the hash table by converting the instance into a
InstanceListSameAttr of the one instance. Aborts if the instance is unlabelled.
If there exists such an instance, it merge the existing InstanceListSameAttr
with the just created one.
- Parameters:
instance - The Instance that is to be inserted.