Esempio n. 1
0
  /**
   * Add an element to the heap conditionally:
   * (1) Add the element if we are not on full capacity.
   * (2) If we are on full capacity, add the element only after comparison.
   */
 bool add (const value_type& value) {
   if (size<K) { heap.push(value); ++size; return true; }
   else if (false==compare(heap.top(),value)) {
     heap.pop ();
     heap.push (value);
     return true;
   } else {
     return false;
   }
 }
Esempio n. 2
0
 void pop () { if (0<size) { heap.pop(); --size; } }