Exemple #1
0
 /// <summary>
 /// Merges the elements of the <see cref="BinaryMinHeap{T}"/> with the other given <see cref="BinaryMinHeap{T}"/>.
 /// </summary>
 /// <param name="otherMinHeap">The other <see cref="BinaryMinHeap{T}"/> used for merging.</param>
 public void Merge(BinaryMinHeap <T> otherMinHeap)
 {
     for (int i = 0; i < otherMinHeap.Count; i++)
     {
         Add(otherMinHeap.array[i]);
     }
 }
Exemple #2
0
        /// <summary>
        /// Returns a new <see cref="BinaryMinHeap{T}"/> containing the elements of the <see cref="BinaryMaxHeap{T}"/>.
        /// </summary>
        /// <returns>Returns a new <see cref="BinaryMinHeap{T}"/> containing the elements of the <see cref="BinaryMaxHeap{T}"/>.</returns>
        public BinaryMinHeap <T> ToMinHeap()
        {
            var minHeap = new BinaryMinHeap <T>(Count, comparer);

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