Esempio n. 1
0
        /// <summary>
        /// Returns a new <see cref="BinaryMaxHeap{T}"/> containing the elements of the <see cref="BinaryMinHeap{T}"/>.
        /// </summary>
        /// <returns>Returns a new <see cref="BinaryMaxHeap{T}"/> containing the elements of the <see cref="BinaryMinHeap{T}"/>.</returns>
        public BinaryMaxHeap <T> ToMaxHeap()
        {
            var maxHeap = new BinaryMaxHeap <T>(Count, comparer);

            maxHeap.Heapify(ToArray());
            return(maxHeap);
        }
Esempio n. 2
0
 /// <summary>
 /// Merges the elements of the <see cref="BinaryMaxHeap{T}"/> with the other given <see cref="BinaryMaxHeap{T}"/>.
 /// </summary>
 /// <param name="otherMaxHeap">The other <see cref="BinaryMaxHeap{T}"/> used for merging.</param>
 public void Merge(BinaryMaxHeap <T> otherMaxHeap)
 {
     for (int i = 0; i < otherMaxHeap.Count; i++)
     {
         Add(otherMaxHeap.array[i]);
     }
 }