include/indexedHeap.h
void maxHeapify(uint32_t i) {
    for (;;) {
      uint32_t left=2*i, right=2*i+1, largest=i;  // find largest of i, L(i), R(i)
      if (left<=_p.size() && _p[left-1]>_p[largest-1]) largest=left;
      if (right<=_p.size() && _p[right-1]>_p[largest-1]) largest=right;
      if (largest == i) return;										// if i's the largest, done
      heapSwap(largest,i);												// otherwise, promote largest by swapping
      i=largest;																	// and push down from i's new position
    }
  }
// Helper function to push position i (index >= 1) down to preserve heap-ness
Helper function to push position i (index >= 1) down to preserve heap-ness
Helper function to push position i ( index > = 1 ) down to preserve heap - ness
void maxHeapify(uint32_t i) {
    for (;;) {
      uint32_t left=2*i, right=2*i+1, largest=i;  
      if (left<=_p.size() && _p[left-1]>_p[largest-1]) largest=left;
      if (right<=_p.size() && _p[right-1]>_p[largest-1]) largest=right;
      if (largest == i) return;										
      heapSwap(largest,i);												
      i=largest;																	
    }
  }
void maxHeapify ( uint32_t i ) { for ( ; ; ) { uint32_t left = 2 * i , right = 2 * i + 1 , largest = i ; if ( left <= _p . size ( ) && _p [ left - 1 ] > _p [ largest - 1 ] ) largest = left ; if ( right <= _p . size ( ) && _p [ right - 1 ] > _p [ largest - 1 ] ) largest = right ; if ( largest == i ) return ; heapSwap ( largest , i ) ; i = largest ; } }
Helper function to push position i (index >= 1) down to preserve heap-ness
Helper function to push position i ( index > = 1 ) down to preserve heap - ness
// find largest of i, L(i), R(i) // if i's the largest, done // otherwise, promote largest by swapping // and push down from i's new position