I have doubts in my mind ::
Currently HashMap in java resizes when totalSize(no of elements inserted) > arrayLength * loadFactor
so that he doubles the table and renames all the key values.
But suppose the hashcode in the Key class is hard-coded to say say 1, so each item will be inserted at index 1 in the linked list. But ours bucketarraywill be an unnecessary resizing to the overall size. Thus, it will continue to increase in size bucketarray, while the elements included in the same bucket, with such a hashcode implementation.
My question is, should you check the size on filled buckets instead of the total size?
I know that such a hash code will interfere with performance. I ask this as a logical question.
source
share