5 * Created by Victor Grishchenko on 4/1/09.
6 * Copyright 2009 Delft University of Technology. All rights reserved.
18 heap_ = (bin_t*) malloc(size_*sizeof(bin_t));
22 bool bincomp (const bin_t& a, const bin_t& b) {
23 register uint64_t ab = a.base_offset(), bb = b.base_offset();
25 return a.layer_bits() < b.layer_bits();
30 bool bincomp_rev (const bin_t& a, const bin_t& b) {
31 register uint64_t ab = a.base_offset(), bb = b.base_offset();
33 return a.layer_bits() > b.layer_bits();
38 bin_t binheap::pop() {
42 std::pop_heap(heap_, heap_+filled_--,bincomp);
43 while (filled_ && ret.contains(heap_[0]))
44 std::pop_heap(heap_, heap_+filled_--,bincomp);
48 void binheap::extend() {
49 std::sort(heap_,heap_+filled_,bincomp_rev);
51 for(int i=1; i<filled_; i++)
52 if (!heap_[solid].contains(heap_[i]))
53 heap_[++solid] = heap_[i];
55 if (2*filled_>size_) {
57 heap_ = (bin_t*) realloc(heap_,size_*sizeof(bin_t));
61 void binheap::push(bin_t val) {
64 heap_[filled_++] = val;
65 std::push_heap(heap_, heap_+filled_,bincomp);