Explore HashMap1.8 expansion

Before expansion

 

After expansion

 mechanism

 

 

the else { // the preserve Order 
    the Node <K, V> loHead = null , loTail = null ; // low pointer 
    the Node <K, V> hiHead = null , hiTail = null ; // the high pointer 
    the Node <K, V> Next;
     do {// tail-interpolation, various interpolation and 1.7, no ring
        Next = e.next;
         // a low chain 
        IF ((e.hash & OLDCAP) == 0 ) {
             IF (loTail == null )
                loHead = e;
            else
                loTail.next = e;
            loTail = e;
        }
        //属于高链表
        else {
            if (hiTail == null)
                hiHead = e;
            else
                hiTail.next = e;
            hiTail = e;
        }
    } while ((e = next) != null);
    if (loTail != null) {
        loTail.next = null;
        newTab[j] = loHead;//newIndex = oldIndex
    }
    if (hiTail != null) {
        hiTail.next = null;
        newTab[j + oldCap] = hiHead;//newIndex = oldIndex + oldCap
    }
}

 

Guess you like

Origin www.cnblogs.com/AllenDuke/p/12287093.html