Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MinMaxMedianHeap&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="comparer">The comparer to use</param>
 /// <param name="capacity">The initial capacity of the heap</param>
 public MinMaxMedianHeap(Comparer <T> comparer, int capacity)
 {
     this.comparer  = comparer;
     lesserOrEqual  = new MinMaxHeap <T>(comparer, capacity / 2);
     greaterOrEqual = new MinMaxHeap <T>(comparer, capacity / 2);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Selects the smaller heap.
 /// </summary>
 /// <param name="whenEqual">The heap to return when equal.</param>
 /// <returns></returns>
 private MinMaxHeap <T> SelectSmallerHeap(MinMaxHeap <T> whenEqual)
 {
     return(lesserOrEqual.Count < greaterOrEqual.Count ? lesserOrEqual : (lesserOrEqual.Count > greaterOrEqual.Count ? greaterOrEqual : whenEqual));
 }