@Override
    public K deleteMin() {
        if (size == 0) {
            throw new NoSuchElementException();
        }

        // find tree with minimum
        RootListNode<K> minRootListNode = rootList.head.suffixMin;
        TreeNode<K> root = minRootListNode.root;

        // remove from list
        SoftHandle<K> result = root.cHead;
        root.cHead = result.next;
        root.cSize--;

        // replenish keys if needed
        if (root.cSize <= targetSize(root.rank) / 2) {
            if (root.left != null || root.right != null) {
                // get keys from children
                sift(root);
                updateSuffixMin(minRootListNode);
            } else if (root.cSize == 0) {
                // no children and empty list, just remove the tree
                RootListNode<K> minRootPrevListNode = minRootListNode.prev;

                if (minRootPrevListNode != null) {
                    minRootPrevListNode.next = minRootListNode.next;
                } else {
                    rootList.head = minRootListNode.next;
                }
                if (minRootListNode.next != null) {
                    minRootListNode.next.prev = minRootPrevListNode;
                } else {
                    rootList.tail = minRootPrevListNode;
                }
                minRootListNode.prev = null;
                minRootListNode.next = null;

                updateSuffixMin(minRootPrevListNode);
            }
        }

        result.next = null;
        size--;
        return result.key;
    }
@ Override public K deleteMin ( ) { if ( size == 0 ) { throw new NoSuchElementException ( ) ; } RootListNode < K > minRootListNode = rootList . head . suffixMin ; TreeNode < K > root = minRootListNode . root ; SoftHandle < K > result = root . cHead ; root . cHead = result . next ; root . cSize -- ; if ( root . cSize <= targetSize ( root . rank ) / 2 ) { if ( root . left != null || root . right != null ) { sift ( root ) ; updateSuffixMin ( minRootListNode ) ; } else if ( root . cSize == 0 ) { RootListNode < K > minRootPrevListNode = minRootListNode . prev ; if ( minRootPrevListNode != null ) { minRootPrevListNode . next = minRootListNode . next ; } else { rootList . head = minRootListNode . next ; } if ( minRootListNode . next != null ) { minRootListNode . next . prev = minRootPrevListNode ; } else { rootList . tail = minRootPrevListNode ; } minRootListNode . prev = null ; minRootListNode . next = null ; updateSuffixMin ( minRootPrevListNode ) ; } } result . next = null ; size -- ; return result . key ; }
{@inheritDoc}