Example #1
0
    public BinomialHeapNode reverse(BinomialHeapNode sibl)
    {
        BinomialHeapNode ret;

        if (sibling != null)
        {
            ret = sibling.reverse(this);
        }
        else
        {
            ret = this;
        }
        sibling = sibl;
        return(ret);
    }
Example #2
0
    public BinomialHeapNode extractMin()
    {
        if (Nodes == null)
        {
            return(null);
        }

        int old_size = size;

        BinomialHeapNode temp = Nodes, prevTemp = null;
        BinomialHeapNode minNode = findMinNode_extractMin(Nodes);

        while (temp.key != minNode.key)
        {
            { /*$goal 0 reachable*/ }
            prevTemp = temp;
            temp     = temp.sibling;
        }

        if (prevTemp == null)
        {
            { /*$goal 1 reachable*/ }
            Nodes = temp.sibling;
        }
        else
        {
            { /*$goal 2 reachable*/ }
            prevTemp.sibling = temp.sibling;
        }
        temp = temp.child;
        BinomialHeapNode fakeNode = temp;

        while (temp != null)
        {
            { /*$goal 3 reachable*/ }
            temp.parent = null;
            temp        = temp.sibling;
        }

        if ((Nodes == null) && (fakeNode == null))
        {
            { /*$goal 4 reachable*/ }
            size = 0;
        }
        else
        {
            if ((Nodes == null) && (fakeNode != null))
            {
                { /*$goal 5 reachable*/ }
                Nodes = fakeNode.reverse(null);
                size--;
            }
            else
            {
                { /*$goal 6 reachable*/ }
                if ((Nodes != null) && (fakeNode == null))
                {
                    { /*$goal 7 reachable*/ }
                    size--;
                }
                else
                {
                    { /*$goal 8 reachable*/ }
                    unionNodes_extractMin(fakeNode.reverse(null));
                    size--;
                }
            }
        }

        if (this.size == 12)
        {
            { /*$goal 9 reachable*/ }
        }
        return(minNode);
    }