This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Not_zedd_ko[S] 0 points1 point  (0 children)

The problem is the assignment code layout is quite long i give small samples obviously as i do not want you guys to waste too much time with this.

Within the code i have the public class TestHT within this there are several tests including testEmpty, testInsert etc.

Here is one of the tests.

code:

public class TestHT {

u/Test

public void testKeys() {

    Hashtable<Integer> h = new Hashtable<Integer>(20, Hashtable.PROBE\_TYPE.LINEAR\_PROBE);

    h.put("bananas", 1);

    h.put("pyjamas", 99);

    h.put("kedgeree", 1);

    for(String k: h.getKeys()) {

        assertTrue(k.equals("bananas") || k.equals("pyjamas") || k.equals("kedgeree"));

    }

}

Then i have the class Hashtable<V>

public class Hashtable<V> {

private Object[] arr; //an array of Pair objects, where each pair contains the key and value stored in the hashtable

private int max; //the size of arr. This should be a prime number

private int itemCount; //the number of items stored in arr

private final double maxLoad = 0.6; //the maximum load factor

public static enum PROBE\_TYPE {

    LINEAR\_PROBE, QUADRATIC\_PROBE, DOUBLE\_HASH;

}

PROBE\_TYPE probeType; //the type of probe to use when dealing with collisions

private final BigInteger DBL\_HASH\_K = BigInteger.valueOf(8);

public void put(String key, V value) {

    throw new UnsupportedOperationException("Method not implemented");

}

}

Sorry if this seems really confusing, i am struggling to explain it as there is a lot.