private void cutNode ( Entry < T > entry ) { /* Begin by clearing the node's mark, since we just cut it. */ entry . mIsMarked = false ; /* Base case: If the node has no parent, we're done. */ if ( entry . mParent == null ) return ; /* Rewire the node's siblings around it, if it has any siblings. */ if ( entry . mNext != entry ) { // Has siblings entry . mNext . mPrev = entry . mPrev ; entry . mPrev . mNext = entry . mNext ; } /* If the node is the one identified by its parent as its child, * we need to rewrite that pointer to point to some arbitrary other * child. */ if ( entry . mParent . mChild == entry ) { /* If there are any other children, pick one of them arbitrarily. */ if ( entry . mNext != entry ) { entry . mParent . mChild = entry . mNext ; } /* Otherwise, there aren't any children left and we should clear the * pointer and drop the node's degree. */ else { entry . mParent . mChild = null ; } } /* Decrease the degree of the parent, since it just lost a child. */ -- entry . mParent . mDegree ; /* Splice this tree into the root list by converting it to a singleton * and invoking the merge subroutine. */ entry . mPrev = entry . mNext = entry ; mMin = mergeLists ( mMin , entry ) ; /* Mark the parent and recursively cut it if it's already been * marked. */ if ( entry . mParent . mIsMarked ) cutNode ( entry . mParent ) ; else entry . mParent . mIsMarked = true ; /* Clear the relocated node's parent; it's now a root. */ entry . mParent = null ; }
Cuts a node from its parent . If the parent was already marked recursively cuts that node from its parent as well .