Пример #1
0
        /// <summary>
        /// Merges the elements of the <see cref="FibonacciMinHeap{T}"/> with the other given <see cref="FibonacciMinHeap{T}"/>. The other <see cref="FibonacciMinHeap{T}"/> is cleared after the merging.
        /// </summary>
        /// <param name="otherMinHeap">The other <see cref="FibonacciMinHeap{T}"/> used for merging.</param>
        public void Merge(FibonacciMinHeap <T> otherMinHeap)
        {
            minNode = MergeNodeLists(minNode, otherMinHeap.minNode);
            Count  += otherMinHeap.Count;

            otherMinHeap.Clear();
        }
Пример #2
0
        /// <summary>
        /// Returns a new <see cref="FibonacciMinHeap{T}"/> containing the elements of the <see cref="FibonacciMaxHeap{T}"/>.
        /// </summary>
        /// <returns>Returns a new <see cref="FibonacciMinHeap{T}"/> containing the elements of the <see cref="FibonacciMaxHeap{T}"/>.</returns>
        public FibonacciMinHeap <T> ToMinHeap()
        {
            var minHeap = new FibonacciMinHeap <T>();

            minHeap.Heapify(ToArray());
            return(minHeap);
        }