void from_array(T* v, int idx, int left, int right) { refreshr[idx] = false; if (left != right) { from_array(v, st_left(idx), left, st_middle(left,right)); from_array(v, st_right(idx), st_middle(left,right)+1, right); tree[idx] = tree[st_left(idx)] + tree[st_right(idx)]; //##// } else tree[idx] = v[left]; }
void update(int idx, int left, int right) { if (refreshr[idx]) { if (left != right) { if (!refreshr[st_left(idx)]) refresh[st_left(idx)] = 0; if (!refreshr[st_right(idx)]) refresh[st_right(idx)] = 0; refresh[st_left(idx)] += refresh[idx]; //##// refresh[st_right(idx)] += refresh[idx]; //##// refreshr[st_left(idx)] = refreshr[st_right(idx)] = true; } tree[idx] += (right-left+1)*refresh[idx]; //##// refreshr[idx] = false; } }
void set(int i, int j, R v, int idx, int left, int right) { update(idx, left, right); if (j < left || right < i) return; if (i <= left && right <= j) { refresh[idx] = v; refreshr[idx] = true; update(idx, left, right); } else { set(i, j, v, st_left(idx), left, st_middle(left,right)); set(i, j, v, st_right(idx), st_middle(left,right)+1, right); tree[idx] = tree[st_left(idx)] + tree[st_right(idx)]; //##// } }
T read(int i, int j, int idx, int left, int right) { update(idx, left, right); if (i <= left && right <= j) return tree[idx]; if (j < left || right < i) return nil; return read(i, j, st_left(idx), left, st_middle(left,right)) + //##// read(i, j, st_right(idx), st_middle(left,right)+1, right); }
static void mm_mark_setup(void) { mm_sys_blk_t *st = 0; mm_ob_class_t *oc = 0; mm_ob_class_t *oc1 = 0; mm_ob_class_t *oc2 = 0; mm_ob_class_t *oc3 = 0; unsigned n = 0; mm_needs_scan = NOMORE; mm_splay_tree = st = splay_extant(mm_splay_tree, 0); while (st) { mm_splay_tree = st = splay_extant(mm_splay_tree, ST_KEYVAL(st)); oc = st->ob_class; n = st->n_ob; st->next = 0; if (oc != oc1 && oc != oc2 && oc != oc3) { memset(oc->quant, 0, sizeof(oc->quant)); (oc1 = oc2, oc2 = oc3, oc3 = oc); } memset(st->mksc, 0, MM_MARK_SZ(n)); st = st_right(st); } }