Skip to content

Commit

Permalink
corrected class name
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanBehnam committed Nov 10, 2019
1 parent ec77066 commit a095495
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public String toString() {
}

@SuppressWarnings("unchecked")
public class HashTableSeperateChaining<K, V> implements Iterable<K> {
public class HashTableSeparateChaining<K, V> implements Iterable<K> {

private static final int DEFAULT_CAPACITY = 3;
private static final double DEFAULT_LOAD_FACTOR = 0.75;
Expand All @@ -42,16 +42,16 @@ public class HashTableSeperateChaining<K, V> implements Iterable<K> {
private int capacity, threshold, size = 0;
private LinkedList<Entry<K, V>>[] table;

public HashTableSeperateChaining() {
public HashTableSeparateChaining() {
this(DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR);
}

public HashTableSeperateChaining(int capacity) {
public HashTableSeparateChaining(int capacity) {
this(capacity, DEFAULT_LOAD_FACTOR);
}

// Designated constructor
public HashTableSeperateChaining(int capacity, double maxLoadFactor) {
public HashTableSeparateChaining(int capacity, double maxLoadFactor) {
if (capacity < 0) throw new IllegalArgumentException("Illegal capacity");
if (maxLoadFactor <= 0 || Double.isNaN(maxLoadFactor) || Double.isInfinite(maxLoadFactor))
throw new IllegalArgumentException("Illegal maxLoadFactor");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import static org.junit.Assert.*;

import com.williamfiset.datastructures.hashtable.HashTableSeperateChaining;
import com.williamfiset.datastructures.hashtable.HashTableSeparateChaining;
import java.util.*;
import org.junit.*;

public class HashTableSeperateChainingTest {
public class HashTableSeparateChainingTest {

// You can set the hash value of this object to be whatever you want
// This makes it great for testing special cases.
Expand Down Expand Up @@ -39,11 +39,11 @@ public boolean equals(Object o) {
MAX_RAND_NUM = randInt(1, 350);
}

HashTableSeperateChaining<Integer, Integer> map;
HashTableSeparateChaining<Integer, Integer> map;

@Before
public void setup() {
map = new HashTableSeperateChaining<>();
map = new HashTableSeparateChaining<>();
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -53,22 +53,22 @@ public void testNullKey() {

@Test(expected = IllegalArgumentException.class)
public void testIllegalCreation1() {
new HashTableSeperateChaining<>(-3, 0.5);
new HashTableSeparateChaining<>(-3, 0.5);
}

@Test(expected = IllegalArgumentException.class)
public void testIllegalCreation2() {
new HashTableSeperateChaining<>(5, Double.POSITIVE_INFINITY);
new HashTableSeparateChaining<>(5, Double.POSITIVE_INFINITY);
}

@Test(expected = IllegalArgumentException.class)
public void testIllegalCreation3() {
new HashTableSeperateChaining<>(6, -0.5);
new HashTableSeparateChaining<>(6, -0.5);
}

@Test
public void testLegalCreation() {
new HashTableSeperateChaining<>(6, 0.9);
new HashTableSeparateChaining<>(6, 0.9);
}

@Test
Expand All @@ -95,7 +95,7 @@ public void testIterator() {
map2.clear();
assertTrue(map.isEmpty());

map = new HashTableSeperateChaining<>();
map = new HashTableSeparateChaining<>();

List<Integer> rand_nums = genRandList(MAX_SIZE);
for (Integer key : rand_nums) assertEquals(map.add(key, key), map2.put(key, key));
Expand Down Expand Up @@ -140,11 +140,11 @@ public void testConcurrentModificationException2() {
@Test
public void randomRemove() {

HashTableSeperateChaining<Integer, Integer> map;
HashTableSeparateChaining<Integer, Integer> map;

for (int loop = 0; loop < LOOPS; loop++) {

map = new HashTableSeperateChaining<>();
map = new HashTableSeparateChaining<>();
map.clear();

// Add some random values
Expand All @@ -167,7 +167,7 @@ public void randomRemove() {
@Test
public void removeTest() {

HashTableSeperateChaining<Integer, Integer> map = new HashTableSeperateChaining<>(7);
HashTableSeparateChaining<Integer, Integer> map = new HashTableSeparateChaining<>(7);

// Add three elements
map.put(11, 0);
Expand All @@ -193,7 +193,7 @@ public void removeTest() {
@Test
public void removeTestComplex1() {

HashTableSeperateChaining<HashObject, Integer> map = new HashTableSeperateChaining<>();
HashTableSeparateChaining<HashObject, Integer> map = new HashTableSeparateChaining<>();

HashObject o1 = new HashObject(88, 1);
HashObject o2 = new HashObject(88, 2);
Expand Down Expand Up @@ -224,7 +224,7 @@ public void testRandomMapOperations() {
jmap.clear();
assertEquals(jmap.size(), map.size());

map = new HashTableSeperateChaining<>();
map = new HashTableSeparateChaining<>();

final double probability1 = Math.random();
final double probability2 = Math.random();
Expand Down Expand Up @@ -255,7 +255,7 @@ public void testRandomMapOperations() {
@Test
public void randomIteratorTests() {

HashTableSeperateChaining<Integer, LinkedList<Integer>> m = new HashTableSeperateChaining<>();
HashTableSeparateChaining<Integer, LinkedList<Integer>> m = new HashTableSeparateChaining<>();
HashMap<Integer, LinkedList<Integer>> hm = new HashMap<>();

for (int loop = 0; loop < LOOPS; loop++) {
Expand All @@ -265,7 +265,7 @@ public void randomIteratorTests() {
assertEquals(m.size(), hm.size());

int sz = randInt(1, MAX_SIZE);
m = new HashTableSeperateChaining<>(sz);
m = new HashTableSeparateChaining<>(sz);
hm = new HashMap<>(sz);

final double probability = Math.random();
Expand Down

0 comments on commit a095495

Please sign in to comment.