Lines Matching defs:heap
35 vec<int> heap; // heap of ints
36 vec<int> indices; // int -> index in heap
40 int x = heap[i];
41 while (parent(i) != 0 && comp(x,heap[parent(i)])){
42 heap[i] = heap[parent(i)];
43 indices[heap[i]] = i;
46 heap [i] = x;
52 int x = heap[i];
53 while (left(i) < heap.size()){
54 int child = right(i) < heap.size() && comp(heap[right(i)],heap[left(i)]) ? right(i) : left(i);
55 if (!comp(heap[child],x)) break;
56 heap[i] = heap[child];
57 indices[heap[i]] = i;
60 heap [i] = x;
67 Heap(C c) : comp(c) { heap.push(-1); }
72 bool empty () { return heap.size() == 1; }
76 indices[n] = heap.size();
77 heap.push(n);
81 int r = heap[1];
82 heap[1] = heap.last();
83 indices[heap[1]] = 1;
85 heap.pop();
86 if (heap.size() > 1)
94 return (size_t)i >= heap.size()
95 || ((parent(i) == 0 || !comp(heap[i],heap[parent(i)])) && heapProperty(left(i)) && heapProperty(right(i))); }