Created
November 29, 2016 01:26
-
-
Save jjlumagbas/503d51ea9aa94ea526d1fbd700824c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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