HashMap icon indicating copy to clipboard operation
HashMap copied to clipboard

Constructor can start selecting the bucketlist size at 2 instead of 1

Open Illation opened this issue 5 years ago • 1 comments

Assuming someone constructed a hash map with a capcity of 0 or 1 elements, and proceeded to add an element, the map would immediately rehash. Since we do not start with a completely empty bucket list anyway, we may as well start at 2. This would also save an iteration of the while loop.

Illation avatar Jan 25 '20 17:01 Illation

Right, it would make sense to either start with not allocating the item storage and/or to start with a minimum of 8 or something reasonable.

rigtorp avatar Feb 07 '20 19:02 rigtorp