Skip to content

Commit eaed788

Browse files
committed
GP-145 Minor fixes
* update put method javadoc * update a test for toString method
1 parent 9c5bc36 commit eaed788

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Diff for: 2-0-data-structures-and-algorithms/2-2-7-hash-table/src/main/java/com/bobocode/cs/HashTable.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ public static int calculateIndex(Object key, int tableCapacity) {
4747
}
4848

4949
/**
50-
* Adds an element to the hash table. Does not support duplicate elements.
50+
* Creates a mapping between provided key and value, and returns the old value. If there was no such key, it returns
51+
* null. {@link HashTable} does not support duplicate keys, so if you put the same key it just overrides the value.
52+
* <p>
53+
* It uses calculateIndex method to find the corresponding array index. Please note, that even different keys can
54+
* produce the same array index.
5155
*
52-
* @param element
53-
* @return true if it was added
56+
* @param key
57+
* @param value
58+
* @return old value or null
5459
*/
5560
@Override
56-
public V put(K element, V value) {
61+
public V put(K key, V value) {
5762
throw new ExerciseNotCompletedException(); // todo:
5863
}
5964

Diff for: 2-0-data-structures-and-algorithms/2-2-7-hash-table/src/test/java/com/bobocode/cs/HashTableTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ void toStringTest() {
470470

471471
String tableStr = hashTable.toString();
472472

473-
assertThat(expectedString).isEqualTo(tableStr);
473+
assertThat(tableStr).isEqualTo(expectedString);
474474
}
475475

476476
}

0 commit comments

Comments
 (0)