void matcher::heap::pop(){ if (len <= 0) return; swap(nodes[1], nodes[len]); swap(heap_p(1), heap_p(len)); len--; heap_down(1); }
void matcher::heap::heap_down(int x) { for (int ma; heap_lc(x) <= len; x = ma){ ma = heap_rc(x) <= len ? (heap_v(heap_lc(x)) > heap_v(heap_rc(x)) ? heap_lc(x) : heap_rc(x)) : heap_lc(x); if (heap_v(x) >= heap_v(ma)) break; swap(nodes[x], nodes[ma]); swap(heap_p(x), heap_p(ma)); } }
void matcher::heap::heap_up(int x){ for (; heap_fa(x)>0 && heap_v(x) > heap_v(heap_fa(x)); ){ swap(nodes[x], nodes[heap_fa(x)]); swap(heap_p(x), heap_p(heap_fa(x))); } }
MRB_API mrb_bool mrb_object_dead_p(mrb_state *mrb, struct RBasic *object) { mrb_gc *gc = &mrb->gc; if (!heap_p(gc, object)) return TRUE; return is_dead(gc, object); }