What does Java use as a default probing method for HashMap? Is it Linear? Chaining or something else?
Looks like chaining to me. Code: (link)
... 724 /** 725 * Create new entry. 726 */ 727 Entry(int h, K k, V v, Entry n) { 728 value = v; 729 next = n; 730 key = k; 731 hash = h; 732 } ... ... 795 void addEntry(int hash, K key, V value, int bucketIndex) { 796 Entry e = table[bucketIndex]; 797 table[bucketIndex] = new Entry(hash, key, value, e); ...
That is, grab the entry at bucketIndex, then replace it with a new entry that has as its "next" field the entry that was already there (i.e. chain it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With