Macaulay2 Engine
Loading...
Searching...
No Matches

◆ insert() [1/2]

void s_pair_heap::insert ( s_pair *& p)

Definition at line 180 of file spair.cpp.

181{
182 heap[0] = merge(p, heap[0]);
183 n_in_heap[0]++;
184 p = nullptr;
185 int i = 0;
186 while (n_in_heap[i] >= spair_heap_size[i])
187 {
188 i++;
189 if (i >= NHEAP)
190 {
191 std::cerr << "too many spairs: aborting" << std::endl;
192 std::cerr << "n_in_heap[" << i << "]=" << n_in_heap[i - 1]
193 << std::endl;
194 abort();
195 }
196 heap[i] = merge(heap[i - 1], heap[i]);
197 n_in_heap[i] += n_in_heap[i - 1];
198 heap[i - 1] = nullptr;
199 n_in_heap[i - 1] = 0;
200 }
201 if (i > top_of_heap) top_of_heap = i;
202 nelems++;
203}
s_pair * heap[NHEAP]
Definition spair.hpp:108
int n_in_heap[NHEAP]
Definition spair.hpp:109
s_pair * merge(s_pair *f, s_pair *g) const
Definition spair.cpp:123
int top_of_heap
Definition spair.hpp:110
int p
static const int spair_heap_size[NHEAP]
Definition spair.cpp:8
const int NHEAP
Definition spair.hpp:102

References heap, merge(), n_in_heap, nelems, NHEAP, p, spair_heap_size, and top_of_heap.

Referenced by put_back().