Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions include/stxxl/bits/containers/parallel_priority_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2769,10 +2769,15 @@ class parallel_priority_queue
for (long p = 0; p < static_cast<long>(m_num_insertion_heaps); ++p)
{
// reestablish heap property: siftUp only those items pushed
for (size_t index = m_proc[p]->heap_add_size; index != 0; ) {
std::push_heap(m_proc[p]->insertion_heap.begin(),
m_proc[p]->insertion_heap.end() - (--index),
m_compare);
// if few items were pushed. Otherwise, rebuild the heap.
if (m_proc[p]->heap_add_size*2 < m_proc[p]->insertion_heap.size()) {
for (size_t index = m_proc[p]->heap_add_size; index != 0; ) {
std::push_heap(m_proc[p]->insertion_heap.begin(),
m_proc[p]->insertion_heap.end() - (--index),
m_compare);
}
} else {
std::make_heap(m_proc[p]->insertion_heap.begin(), m_proc[p]->insertion_heap.end(), m_compare);
}

#if STXXL_PARALLEL
Expand Down