JML

org.multijava.util.jperf
Class Table

java.lang.Object
  extended byorg.multijava.util.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.


Field Summary
private  Hashtable[] heads
          Variable holding all table heads for T1 and T2, respectively.
private  char maxCharValue
           
private  int maxWordLength
           
private  char minCharValue
           
private static Random random
          The random number generator for generating values of T1 and T2.
private  String tableName
           
 
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
 

Field Detail

random

private static Random random
The random number generator for generating values of T1 and T2. It is shared by all tables, thus this variable is a class variable.


tableName

private final String tableName

maxWordLength

private final int maxWordLength

minCharValue

private final char minCharValue

maxCharValue

private final char maxCharValue

heads

private Hashtable[] heads
Variable holding all table heads for T1 and T2, respectively. Thus this variable is an instance variable. A table head is a Vector holding character-value pairs for a whole row.

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.

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.