mjc

org.multijava.util.jperf
Class JPerf

java.lang.Object
  extended byorg.multijava.util.jperf.JPerf

public class JPerf
extends Object

This class represents the perfect hashing function generator


Field Summary
private  String[] EQUALS_FUNCTION
           
private  String[] FIND_FUNCTION
           
private  String[] footer
           
private  Graph graph
           
private  String[] HASH_FUNCTION
           
private  String[] header
           
private  Keywords keywords
           
private  long maxNodeCount
           
private  Table table1
           
private  Table table2
           
 
Constructor Summary
JPerf(String[] keywords, String[] header, String[] footer)
          Constructs a JPerf object with default load factor.
JPerf(String[] keywords, String[] header, String[] footer, double loadFactor)
          Constructs a JPerf object
 
Method Summary
private  boolean addKey(String key, long value)
          Adds a `key -> value' pair.
 void build()
          Builds tables and graph.
 void genCode(String fileName)
          Dumps result to class source.
private  void printStringArray(PrintWriter out, String[] lines)
          Prints a string array to the output file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS_FUNCTION

private final String[] EQUALS_FUNCTION

HASH_FUNCTION

private final String[] HASH_FUNCTION

FIND_FUNCTION

private final String[] FIND_FUNCTION

keywords

private final Keywords keywords

header

private final String[] header

footer

private final String[] footer

maxNodeCount

private final long maxNodeCount

table1

private Table table1

table2

private Table table2

graph

private Graph graph
Constructor Detail

JPerf

public JPerf(String[] keywords,
             String[] header,
             String[] footer,
             double loadFactor)
Constructs a JPerf object

Parameters:
keywords - the keywords to hash
header - the verbatim part to output at the beginning of the file
footer - the verbatim part to output at the end of the file

JPerf

public JPerf(String[] keywords,
             String[] header,
             String[] footer)
Constructs a JPerf object with default load factor.

Parameters:
keywords - the keywords to hash
header - the verbatim part to output at the beginning of the file
footer - the verbatim part to output at the end of the file
Method Detail

build

public void build()
Builds tables and graph. Tasks: 1. generate the tables table1 and table2; 2. generate the graph 3. assure that the graph is acyclic


addKey

private boolean addKey(String key,
                       long value)
Adds a `key -> value' pair.

Returns:
true iff the graph is still acyclic

genCode

public void genCode(String fileName)
             throws IOException
Dumps result to class source.

Parameters:
fileName - the name of the output file.
Throws:
IOException

printStringArray

private void printStringArray(PrintWriter out,
                              String[] lines)
Prints a string array to the output file. Each element is written on a separate line.


mjc

mjc is Copyright (C) 2000-2004 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. mjc is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.