static void test_rb(void) { //rbtree *tr = rb_cnew( 0, 0, 0, 0, 0, 0); rbtree *tr = rb_new(); char keybuf[100]; size_t valuebuf[] = { 1 }; size_t *vp; // while (fscanf(stdin, "%s", keybuf) == 1) { // vp = rb_get(tr, keybuf); // if (vp) // *vp += 1; // else // rb_add(tr, keybuf, valuebuf); // } // this is another faster version while (fscanf(stdin, "%s", keybuf) == 1) { vp = rb_fget(tr, keybuf); *vp += 1; } rb_set(tr, "a", valuebuf); *valuebuf = 123456789; rb_add(tr, "b", valuebuf); *valuebuf = 2; rb_set(tr, "c", valuebuf); rb_set(tr, "d", valuebuf); *valuebuf = 987654321; rb_update(tr,"a",valuebuf); rb_set(tr, "e", valuebuf); rb_print(tr); rb_clear(tr); rb_clear(tr); //just for test rb_free(tr); }
int Update(unsigned long *random_seed, param_t *params) { int errors = 0; void *value; long int_value; int_value = get_random(random_seed) % params->scale + 1; value = rb_update(My_Tree, int_value); if (value == NULL) errors++; return errors; }