bool nodeset_resize (nodeset_t *n, uint32_t size) { assert (n->magic == NS_MAGIC); uint32_t r; Veb T; if (size < veb_minsize) /* don't allow size below minimum */ size = veb_minsize; if (size < NS_SIZE (n)) { /* If shrinking, bump size up to */ r = NS_FIRST (n); /* fit highest rank in set. */ while (r < NS_SIZE (n)) { if (r >= size) size = r + 1; r = NS_NEXT (n, r); } } if (size != NS_SIZE (n)) { T = vebnew (size, 0); if (!T.D) oom (); r = NS_FIRST (n); while (r < NS_SIZE (n)) { vebput (T, r); r = NS_NEXT (n, r); } free (n->T.D); n->T = T; } return true; }
Veb fill(uint M) { Veb T = vebnew(M,1); for (int i = 0; i < 0xff; ++i) { uint x = rand()%M; vebdel(T,x); test(vebpred(T,x) != x); } return T; }
nodeset_t *nodeset_create_size (uint32_t size) { nodeset_t *n = malloc (sizeof (*n)); if (!n) oom (); n->magic = NS_MAGIC; n->refcount = 1; n->T = vebnew (size, 0); if (!n->T.D) oom (); n->conf_separator[0] = ','; n->conf_separator[1] = '\0'; n->conf_ranges = true; n->conf_brackets = true; n->conf_padding = 0; n->s = NULL; n->s_size = 0; n->s_valid = false; return n; }