JanosVM v1.0 API

edu.utah.janosvm.kit.util
Class SharedTable

java.lang.Object
  |
  +--edu.utah.janosvm.kit.util.SharedTable

class SharedTable
extends java.lang.Object

The SharedTable class is the core implementation of a hash table that can be shared between multiple teams.


Field Summary
private  int depth
          The table's position in the stack.
private static int DEPTH_THRESHOLD
          The maximum number of SharedTable object's to stack together.
private  Association[] entries
          The array of references to Associations for this table.
private  int entryCount
          The number of entries in this table.
private static int INITIAL_OVERFLOW_SIZE
          Default overflow array size for a new shared table.
private static int INITIAL_PRIMARY_SIZE
          Default primary array size for a new shared table.
private  SharedTable lastGeneration
          Link to the next table in the stack.
private  int[] overflowLink
          Array of indexes that link the collision list together.
private  int overflowTableSize
          The size of the overflow array.
private  int overflowTableUsed
          The number of slots used in the overflow array.
private  int primaryTableSize
          The size of the primary hash table.
 
Constructor Summary
  SharedTable()
          Construct a SharedTable with the default primary and overflow array sizes.
private SharedTable(int primarySize, int overflowSize)
          Construct a SharedTable with the given primary and overflow array sizes.
 
Method Summary
(package private)  java.lang.Object get(java.lang.Object name)
          Get an Association from the table using the given identifier object.
 int getEntryCount()
           
 int getTotalEntryCount()
           
private  int hashName(java.lang.Object name)
          Compute the hash for the given identitifer object.
(package private)  SharedTable merge(SharedTable diff, boolean collapse)
          Merge the current table with the differences introduced by another table.
(package private)  void put(Association assoc)
          Put an Association into the table.
private  void remove(java.lang.Object name)
          Remove an Association with the given identifier from the table.
 void walk(SharedTableWriter stw, SharedTableWalker walker)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait, wait0
 

Field Detail

DEPTH_THRESHOLD

private static final int DEPTH_THRESHOLD
The maximum number of SharedTable object's to stack together.

INITIAL_PRIMARY_SIZE

private static final int INITIAL_PRIMARY_SIZE
Default primary array size for a new shared table.

INITIAL_OVERFLOW_SIZE

private static final int INITIAL_OVERFLOW_SIZE
Default overflow array size for a new shared table.

lastGeneration

private SharedTable lastGeneration
Link to the next table in the stack.

depth

private int depth
The table's position in the stack. The bottom of the stack is 0, positive numbers for the upper elements of the stack.

entries

private Association[] entries
The array of references to Associations for this table.

primaryTableSize

private final int primaryTableSize
The size of the primary hash table.

overflowLink

private int[] overflowLink
Array of indexes that link the collision list together.

overflowTableUsed

private int overflowTableUsed
The number of slots used in the overflow array.

overflowTableSize

private final int overflowTableSize
The size of the overflow array.

entryCount

private int entryCount
The number of entries in this table.
Constructor Detail

SharedTable

public SharedTable()
Construct a SharedTable with the default primary and overflow array sizes.

SharedTable

private SharedTable(int primarySize,
                    int overflowSize)
Construct a SharedTable with the given primary and overflow array sizes.
Parameters:
primarySize - The size of the primary hash table array.
overflowSize - The size of the overflow array for the table.
Method Detail

getEntryCount

public int getEntryCount()
Returns:
The number of entries in this table.

getTotalEntryCount

public int getTotalEntryCount()
Returns:
The number of entries in the stack of tables.

hashName

private int hashName(java.lang.Object name)
Compute the hash for the given identitifer object.
Parameters:
name - The identifier to hash.
Returns:
A hash index that is between zero and this.primaryTableSize, inclusive.

put

void put(Association assoc)
   throws TableFullException
Put an Association into the table.
Parameters:
assoc - The Association object to put in the table.
Throws:
Throws - TableFullException if the overflow array is full and can't accomodate anymore elements.

get

java.lang.Object get(java.lang.Object name)
Get an Association from the table using the given identifier object.
Parameters:
name - The identifier to lookup in the table.
Returns:
The object associated with `name'.

remove

private void remove(java.lang.Object name)
Remove an Association with the given identifier from the table. This is private since it can only be used by merge() on an unshared table.
Parameters:
name - The identifier to lookup and remove from the table.

walk

public void walk(SharedTableWriter stw,
                 SharedTableWalker walker)

merge

SharedTable merge(SharedTable diff,
                  boolean collapse)
Merge the current table with the differences introduced by another table.
Parameters:
diff - A table containing changes to the current table.
collapse - Force the stack of tables to be coalesced into a
collapse - single table.
Returns:
Either the `diff' table thats been connected to the current

JanosVM v1.0 API

This documentation is Copyright (C) 2000-2003 The University of Utah. All Rights Reserved. See the documentation license for distribution terms and restrictions.
Documentation, software, and mailing lists for the JanosVM can be found at the Janos Project web page: http://www.cs.utah.edu/flux/janos/
Generated on Feb 13, 2003