void heapify(std::vector<int>& data, int index, int size) { int value = data[index]; int childIndex = getMaxChildIndex(data, index, size); while (childIndex < size && data[childIndex] > value) { data[index] = data[childIndex]; index = childIndex; childIndex = getMaxChildIndex(data, index, size); ++whileCount; } data[index] = value; }
int D_HEAP<KeyType>::minChild(int parent) const { if (parent * d_ + 1 > sizeTree_ - 1) return -1; int minCh = getMinChildIndex(parent); int maxCh = min(getMaxChildIndex(parent), sizeTree_ - 1); for (int i = minCh; i <= maxCh; i++) { if (tree_[i] < tree_[minCh]) { minCh = i; } } return minCh; }
int D_HEAP<KeyType>::getReallocSize(void) const { int maxChild = getMaxChildIndex(getParentIndex(sizeTree_ - 1)); return (d_ - maxChild % d_); }