Hi, can someone help me with an implementation of a hash map, I tried to do the TODO this way, but it shows an error.
// DEFAULT_CAPACITY has to be a prime number
private static final int DEFAULT_CAPACITY = 23;
private static final float DEFAULT_LOAD_FACTOR = 0.5f;
private static final int CAPACITY_INCREASE_FACTOR = 2;
private Node<KeyType, DataType>[] map;
private int size = 0;
private int capacity;
private final float loadFactor; // Compression factor
public HashMap() { this(DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR); }
public HashMap(int initialCapacity) {
this(initialCapacity, DEFAULT_LOAD_FACTOR);
}
/** TODO
* Define capacity, loadFactor and map
*/
public HashMap(int initialCapacity, float loadFactor) {
this.loadFactor = Math.abs(loadFactor);
return new HashMap<Integer, Integer>(initialCapacity, loadFactor); --> ERROR
}```