Skip to content

Instantly share code, notes, and snippets.

@jjlumagbas
Created November 29, 2016 01:26
Show Gist options
  • Select an option

  • Save jjlumagbas/503d51ea9aa94ea526d1fbd700824c43 to your computer and use it in GitHub Desktop.

Select an option

Save jjlumagbas/503d51ea9aa94ea526d1fbd700824c43 to your computer and use it in GitHub Desktop.
import java.util.LinkedList;
import java.util.List;
public class HashTable<V> {
private int capacity;
private List<V>[] buckets;
public HashTable(int capacity) {
this.capacity = capacity;
this.buckets = new LinkedList[capacity];
}
public void add(V value) {
}
public void remove(V value) {
}
public boolean contains(V value) {
return false;
}
}
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class HashTableTest {
HashTable<String> t;
@Before
public void setUp() throws Exception {
t = new HashTable<>(10);
}
@Test
public void add() throws Exception {
t.add("Hello");
assertTrue(t.contains("Hello"));
}
@Test
public void remove() throws Exception {
fail();
}
@Test
public void contains() throws Exception {
fail();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment