Skip to content
On this page

d65_q3b_heap_check.cpp

cpp
#pragma region student.h
#ifndef __STUDENT_H
#define __STUDENT_H

#ifndef DEBUG
#include "priority_queue.h"
#endif

template <typename T, typename Comp>
bool CP::priority_queue<T, Comp>::check() {
    for (int front = 1; front < mSize; front++) {
        const int parent = (front - 1) / 2;

#ifdef DEBUG
        const auto parentValue = mData[parent];
        const auto frontValue = mData[front];
#endif

        if (mLess(mData[parent], mData[front])) {
            return false;
        }
    }

    return true;
}

#endif
#pragma endregion student.h

See on GitHub

Last Updated: 15/1/2567 13:25:21 (UTC+7)

Released under the MIT License