/*************************************************************** This is part of the code you will use for the hash table in Program 3, INFS 519. ***************************************************************/ import java.util.*; public class Table, U> { private final int SIZE = 0; // YOU MUST CHANGE THIS TO *YOUR* VALUE @SuppressWarnings("unchecked") // not necessary but convenient // a[] is the array of head pointers for synonym chains private Node[] a = (Node[])new Node[SIZE]; private Node cursor; // "current" node in listing of table elements private int cursorIndex = -1; // current sysnonym chain in table listing /*************************************************************** You will but your code to implement the table here. ***************************************************************/ /*************************************************************** The following four methods are used for listing all elements of the table. They are used in the "print all" and "write to file" operations DO NOT MODIFY ANYTHING BELOW HERE. ***************************************************************/ // places cursor on first node in table public void startList() { cursorIndex = -1; // prepare to start listing cursor = null; advanceCursor(); // find first non-null node in list } /* advances cursor to next record in table and returns the (previous) current record -- requires cursor is not null */ public Record nextRecord() { Record retVal = cursor.record; advanceCursor(); return retVal; } // determines whether any records remain to be listed public boolean hasNextRecord() { return cursor != null; } // moves cursor to next node in the table or sets to null if at end of table private void advanceCursor() { /* cursor == null case is for starting a listing and cursor.next == null is for at end of one list */ if (cursor == null || cursor.next == null) { cursorIndex++; // corsorIndex is now 0 if starting // find next non-empty synonym chain while (cursorIndex < SIZE && a[cursorIndex] == null) cursorIndex++; if (cursorIndex < SIZE) // s[cursorIndex] != null cursor = a[cursorIndex]; // point cursor to first node in chain else cursor = null; // have reached the end of the hash table } else cursor = cursor.next; // advance in synonym chain } /*************************************************************** The following inner class is the node class to be used in your implementation of the synonym chains. ***************************************************************/ private class Node, U> { public Record record; public Node next; public Node(T t, U u) { record = new Record(t, u); } /* get and set methods are not neeced since the class Node is not visible outside of Table */ } }