What does Java use as a default probing method for HashMap? Is it Linear? Chaining or something else?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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).