I have a doubt to my mind ::
Currently HashMap in java, resizes when totalSize(no of elements inserted) > arrayLength * loadFactor
so it doubles the table and rehashes all key-value.
But suppose hashcode in Key class is hardcoded to let's say 1, so everytime elements will be inserted at index 1 in linked list manner. But our bucketarray
will unnecessary resize on total size. So it will keep on increasing bucketarray
size while elements going in the same bucket with such hashcode implementation.
I have a question, should we not check resize on filled buckets, instead of total size ??
I know such hashcode will hamper the performance. I am asking this as a logical question.