Skip to content

Instantly share code, notes, and snippets.

@jinhao08
jinhao08 / HashTable.java
Created March 27, 2018 22:03 — forked from amadamala/HashTable.java
HashTable implementation in Java
public class HashTable {
private static int INITIAL_SIZE = 16;
private HashEntry[] entries = new HashEntry[INITIAL_SIZE];
public void put(String key, String value) {
int hash = getHash(key);
final HashEntry hashEntry = new HashEntry(key, value);
if(entries[hash] == null) {
entries[hash] = hashEntry;
}
// If there is already an entry at current hash