private int insertNodeBetween ( int index , int nextIndex , long node ) { assert ( previousIndexFromNode ( node ) == 0 ) ; assert ( nextIndexFromNode ( node ) == 0 ) ; assert ( nextIndexFromNode ( nodes . elementAti ( index ) ) == nextIndex ) ; // Append the new node and link it to the existing nodes. int newIndex = nodes . size ( ) ; node |= nodeFromPreviousIndex ( index ) | nodeFromNextIndex ( nextIndex ) ; nodes . addElement ( node ) ; // nodes[index].nextIndex = newIndex node = nodes . elementAti ( index ) ; nodes . setElementAt ( changeNodeNextIndex ( node , newIndex ) , index ) ; // nodes[nextIndex].previousIndex = newIndex if ( nextIndex != 0 ) { node = nodes . elementAti ( nextIndex ) ; nodes . setElementAt ( changeNodePreviousIndex ( node , newIndex ) , nextIndex ) ; } return newIndex ; }
Inserts a new node into the list between list - adjacent items . The node s previous and next indexes must not be set yet .