at.dms.compiler.tools.jperf
Class Table

java.lang.Object
  extended by at.dms.compiler.tools.jperf.Table

public class Table
extends Object

This class is the internal representation of the tables T1 and T2. The meaning of T1 and T2 could be found in explanations of GGPerf's algorithm.


Constructor Summary
Table(String tableName, int maxWordLength, char minCharValue, char maxCharValue)
          Creates an instance of table representing one of T1 and T2.
 
Method Summary
 void genCode(PrintWriter out)
          Outputs the contents of the table as a data structure, normally an array.
 long getKeyValue(String key)
          Returns the value previously assigned to the key
 void init()
          Initialises the internal structures
 long insertKey(String key, long max)
          Inserts the key into the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Table

public Table(String tableName,
             int maxWordLength,
             char minCharValue,
             char maxCharValue)
Creates an instance of table representing one of T1 and T2.

Parameters:
tableName - the name of the table
maxWordLength - the maximum length of a keyword
minCharValue - the smallest ASCII value in all keys
maxCharValue - the largest ASCII value in all keys?
Method Detail

init

public void init()
Initialises the internal structures


insertKey

public long insertKey(String key,
                      long max)
Inserts the key into the table. A randomly generated value is assigned to be the table value correspondent to each character.

Parameters:
key - the key to insert
max - the maximum value
Returns:
the sum of the values assigned to each character

getKeyValue

public long getKeyValue(String key)
Returns the value previously assigned to the key

Parameters:
key - the key

genCode

public void genCode(PrintWriter out)
Outputs the contents of the table as a data structure, normally an array.

Parameters:
out - the output stream.