We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
void HeapTimer::del_(size_t index) { /* 删除指定位置的结点 / assert(!heap_.empty() && index >= 0 && index < heap_.size()); / 将要删除的结点换到队尾,然后调整堆 */ size_t i = index; size_t n = heap_.size() - 1; assert(i <= n); if(i < n) { SwapNode_(i, n); if(!siftdown_(i, n)) { siftup_(i); } } 这里的siftdown_(i,n)是否应该是siftdown(i,n-1)?
The text was updated successfully, but these errors were encountered:
这里没有错,n已经是size() - 1了
Sorry, something went wrong.
void HeapTimer::del_(size_t index) { /* 删除指定位置的结点 / assert(!heap.empty() && index >= 0 && index < heap_.size()); /_ 将要删除的结点换到队尾,然后调整堆 */ size_t i = index; size_t n = heap_.size() - 1; assert(i <= n); if(i < n) { SwapNode_(i, n); if(!siftdown_(i, n)) { siftup_(i); } } 这里的siftdown_(i,n)是否应该是siftdown(i,n-1)?
没有问题,因为n=size()-1,并且siftdown中while循环的条件为j<n
No branches or pull requests
void HeapTimer::del_(size_t index) {
/* 删除指定位置的结点 /
assert(!heap_.empty() && index >= 0 && index < heap_.size());
/ 将要删除的结点换到队尾,然后调整堆 */
size_t i = index;
size_t n = heap_.size() - 1;
assert(i <= n);
if(i < n) {
SwapNode_(i, n);
if(!siftdown_(i, n)) {
siftup_(i);
}
}
这里的siftdown_(i,n)是否应该是siftdown(i,n-1)?
The text was updated successfully, but these errors were encountered: