Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

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

Lines changed: 9 additions & 4 deletions
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

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

Lines changed: 1 addition & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /