finalinthash(Objectk){inth=hashSeed;if(0!=h&&kinstanceofString){returnsun.misc.Hashing.stringHash32((String)k);}h^=k.hashCode();// This function ensures that hashCodes that differ only by// constant multiples at each bit position have a bounded// number of collisions (approximately 8 at default load factor).h^=(h>>>20)^(h>>>12);returnh^(h>>>7)^(h>>>4);}
/** * Inserts this entry before the specified existing entry in the list. */privatevoidaddBefore(Entry<K,V>existingEntry){after=existingEntry;before=existingEntry.before;before.after=this;after.before=this;}/** * This method is invoked by the superclass whenever the value * of a pre-existing entry is read by Map.get or modified by Map.set. * If the enclosing Map is access-ordered, it moves the entry * to the end of the list; otherwise, it does nothing. */voidrecordAccess(HashMap<K,V>m){LinkedHashMap<K,V>lm=(LinkedHashMap<K,V>)m;if(lm.accessOrder){lm.modCount++;remove();addBefore(lm.header);}}
/** * Expunges stale entries from the table. */privatevoidexpungeStaleEntries(){for(Objectx;(x=queue.poll())!=null;){synchronized(queue){@SuppressWarnings("unchecked")Entry<K,V>e=(Entry<K,V>)x;inti=indexFor(e.hash,table.length);Entry<K,V>prev=table[i];Entry<K,V>p=prev;while(p!=null){Entry<K,V>next=p.next;if(p==e){if(prev==e)table[i]=next;elseprev.next=next;// Must not null out e.next;// stale entries may be in use by a HashIteratore.value=null;// Help GCsize--;break;}prev=p;p=next;}}}