public class TTT_HC
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
private static int |
ARRAY_SIZE |
Length of the winner array.
|
private static int |
ERROR_CODE |
An integer constant holding the number (1) that is passed to System.exit()
after certain conditions occur
|
private static int |
NUMBER_OF_WINNERS |
The number of winning TicTacToe Strings
|
private static char |
O |
A char holding an o
|
private static int[] |
POWERS_OF_THREE |
A lookup table with powers of three where the each spot holds three ^ index
|
private static char |
SPACE |
A char holding a space
|
private static java.lang.String |
WINNER_FILE |
The name of the file with the TicTacToe winners
|
private static java.lang.String |
WINNER_FILE_NOT_FOUND |
The error message used if the file with the winners is not found
|
private HashNode[] |
winners |
The winners array which will store the Strings of all the possible
TicTacToe winners using HashNodes
|
private static char |
X |
A char holding an x
|
| Constructor | Description |
|---|---|
TTT_HC() |
This creates a TTT_HC by instantiating and filling the winners array of HashNodes
which should hold all of the winning Strings at their proper hash code
index.
|
| Modifier and Type | Method | Description |
|---|---|---|
static void |
analyzeAndPrint(int arraySize,
java.util.ArrayList<java.lang.Integer> chainLengths,
java.util.ArrayList<HashNode> entrySpots,
java.util.ArrayList<HashNode> collisionSpots,
int emptySpaces) |
Analyzes and prints the required information surrounding the winners method
which is: size of the array, load factor, the number of chains,
the maximum chain length, the average chain length, the number
of entries per quarter and the number of collisions per tenth.
|
static void |
main(java.lang.String[] args) |
|
int |
tttHashCode(java.lang.String str) |
Returns a hash code for each winner to be stored.
|
private HashNode[] winners
private static final java.lang.String WINNER_FILE
private static final java.lang.String WINNER_FILE_NOT_FOUND
private static final int[] POWERS_OF_THREE
private static final char SPACE
private static final char X
private static final char O
private static final int ERROR_CODE
private static final int NUMBER_OF_WINNERS
private static final int ARRAY_SIZE
TTT_HC()
public int tttHashCode(java.lang.String str)
str - the String to create a hash code forpublic static void analyzeAndPrint(int arraySize,
java.util.ArrayList<java.lang.Integer> chainLengths,
java.util.ArrayList<HashNode> entrySpots,
java.util.ArrayList<HashNode> collisionSpots,
int emptySpaces)
arraySize - the size of the array to be analyzedchainLengths - an ArrayList of all of the chainLengths (greater
than 1) found in the array being analyzedentrySpots - an ArrayList of the HashNodes that are directly located
in winnerscollisionSpots - an ArrayList of the HashNodes where collisions occurredemptySpaces - the number of empty spots in the winners arraypublic static void main(java.lang.String[] args)