public TVertex Dequeue()
        {
            var result = heap.Top;

            //Contract.Assert(result != null);
            heap.Dequeue();
            return(result.Value);
        }
Exemple #2
0
        public IEnumerator <KeyValuePair <TPriority, TValue> > GetEnumerator()
        {
            var tempHeap  = new FibonacciHeap <TPriority, TValue>(this.Direction, this.priorityComparsion);
            var nodeStack = new Stack <FibonacciHeapCell <TPriority, TValue> >();

            LambdaHelpers.ForEach(nodes, x => nodeStack.Push(x));
            while (nodeStack.Count > 0)
            {
                var topNode = nodeStack.Peek();
                tempHeap.Enqueue(topNode.Priority, topNode.Value);
                nodeStack.Pop();
                LambdaHelpers.ForEach(topNode.Children, x => nodeStack.Push(x));
            }
            while (!tempHeap.IsEmpty)
            {
                yield return(tempHeap.Top.ToKeyValuePair());

                tempHeap.Dequeue();
            }
        }