
/**
 * A program to test the QuadraticProbeHashTable.
 *
 * @author Mark Young (A00000000)
 */
public class MakeHT {

    public static void main(String[] args) {
        // create and populate the HT.
        QuadraticProbeHashTable ht = new QuadraticProbeHashTable();
        insertAll(ht, new int[]{31, 8, 12, 99, 18, 4, 11, 99, 55, 42});
        
        // check the HT for various values
        for (int i = 1; i <= 10; ++i) {
            System.out.println("BST contains " + i + "? "
                + ht.contains(i));
        }
        
        // print the HT
        System.out.println(ht);
    }

    /**
     * Inserts every integer from the given array into the given HT.
     *
     * @param ht the HT to insert into.
     * @param arr the numbers to insert into the HT.
     */
    private static void insertAll(QuadraticProbeHashTable ht, int[] arr) {
        for (int num : arr) {
            if (ht.insert(num)) {
                System.out.println("Inserted " + num);
            } else {
                System.out.println("Failed to insert " + num);
            }
        }
    }

}
