You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think improvement is needed in the bucketInsertEntry () method, because by going through this situation according to the bucket value being null in 152 rows, the same condition may appear as return null in the bucketSeekEntry method, accordingly we understand that there is no addition in that index according to the bucketIndex-given in the condition of correctness of the condition in 152 rows. Therefore, I think there is no need for additional checking, so it should not be logged into the bucketSeekEntry () method, we can do such a refactoring by considering these (I sampled the change over your codes):
private V bucketInsertEntry (int bucketIndex, Entry <K, V> entry) {
LinkedList <Entry <K, V >> bucket = table [bucketIndex];
if (bucket == null) {
table [bucketIndex] = bucket = new LinkedList<>();
bucket.add (entry);
if (++ size> threshold) resizeTable ();
return null; // Use null to indicate that there was no previous entry
}
Entry <K, V> existentEntry = bucketSeekEntry (bucketIndex, entry.key);
if (!existentEntry == null) {
V oldVal = existentEntry.value;
existentEntry.value = entry.value;
return oldVal;
}
return null;
}
The text was updated successfully, but these errors were encountered:
https://github.com/williamfiset/data-structures/blob/b63739f38cbc405d5d2ebcbae2ce02f37bde35fe/com/williamfiset/datastructures/hashtable/HashTableSeparateChaining.java#L152
I think improvement is needed in the bucketInsertEntry () method, because by going through this situation according to the bucket value being null in 152 rows, the same condition may appear as return null in the bucketSeekEntry method, accordingly we understand that there is no addition in that index according to the bucketIndex-given in the condition of correctness of the condition in 152 rows. Therefore, I think there is no need for additional checking, so it should not be logged into the bucketSeekEntry () method, we can do such a refactoring by considering these (I sampled the change over your codes):
The text was updated successfully, but these errors were encountered: