public E poll()

in src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java [351:406]


    public E poll()
    {
        // 2  if z ≠ NIL
        if ( isEmpty() )
        {
            return null;
        }

        // 1  z <- min[H]
        FibonacciHeapNode<E> z = minimumNode;
        int numOfKids = z.getDegree();

        FibonacciHeapNode<E> x = z.getChild();
        FibonacciHeapNode<E> tempRight;

        while ( numOfKids > 0 )
        {
            // 3  for each child x of z
            tempRight = x.getRight();

            // 4  do add x to the root list of H
            moveToRoot( x );

            // 5  p[x] <- NIL
            x.setParent( null );

            x = tempRight;
            numOfKids--;
        }

        // 6  remove z from the root list of H
        z.getLeft().setRight( z.getRight() );
        z.getRight().setLeft( z.getLeft() );

        // 7  if z = right[z]
        if ( z == z.getRight() )
        {
            // 8  min[H] <- NIL
            minimumNode = null;
        }
        else
        {
            // 9  min[H] <- right[z]
            minimumNode = z.getRight();
            // 10  CONSOLIDATE(H)
            consolidate();
        }

        // 11  n[H] <- n[H] - 1
        size--;

        E minimum = z.getElement();
        elementsIndex.remove( minimum );
        // 12  return z
        return minimum;
    }