public class MakeHT
2: /**
3: * A program to test the QuadraticProbeHashTable.
4: *
5: * @author Mark Young (A00000000)
6: */
7: public class MakeHT {
9: public static void main(String[] args) {
10: // create and populate the HT.
11: QuadraticProbeHashTable ht = new QuadraticProbeHashTable();
12: insertAll(ht, new int[]{31, 8, 12, 99, 18, 4, 11, 99, 55, 42});
13:
14: // check the HT for various values
15: for (int i = 1; i <= 10; ++i) {
16: System.out.println("BST contains " + i + "? "
17: + ht.contains(i));
18: }
19:
20: // print the HT
21: System.out.println(ht);
22: }
24: /**
25: * Inserts every integer from the given array into the given HT.
26: *
27: * @param ht the HT to insert into.
28: * @param arr the numbers to insert into the HT.
29: */
30: private static void insertAll(QuadraticProbeHashTable ht, int[] arr) {
31: for (int num : arr) {
32: if (ht.insert(num)) {
33: System.out.println("Inserted " + num);
34: } else {
35: System.out.println("Failed to insert " + num);
36: }
37: }
38: }
40: }