bitset_countn_t *bitset_countn_new(unsigned n, size_t size) { bitset_countn_t *counter = bitset_malloc(sizeof(bitset_countn_t)); if (!counter) { bitset_oom(); } assert(n); counter->n = n; size = (size_t)(size / BITSET_LITERAL_LENGTH) + 1; size_t pow2; BITSET_NEXT_POW2(pow2, size); counter->size = pow2; counter->words = bitset_malloc(sizeof(bitset_word *) * (counter->n + 1)); if (!counter->words) { bitset_oom(); } //Create N+1 uncompressed bitsets size_t i; for ( i = 0; i <= n; i++) { counter->words[i] = bitset_calloc(1, counter->size * sizeof(bitset_word)); if (!counter->words[i]) { bitset_oom(); } } return counter; }
bitset_vector_t *bitset_vector_new() { bitset_vector_t *vector = bitset_malloc(sizeof(bitset_vector_t)); if (!vector) { bitset_oom(); } vector->buffer = bitset_malloc(sizeof(char)); if (!vector->buffer) { bitset_oom(); } vector->tail_offset = 0; vector->size = 1; vector->length = 0; return vector; }
bipartite_t *bipartite_new(unsigned const n_left, unsigned const n_right) { bipartite_t *gr = XMALLOCFZ(bipartite_t, adj, n_left); gr->n_left = n_left; gr->n_right = n_right; for (unsigned i = 0; i < n_left; ++i) gr->adj[i] = bitset_malloc(n_right); return gr; }
bitset_linear_t *bitset_linear_new(size_t size) { bitset_linear_t *counter = bitset_malloc(sizeof(bitset_linear_t)); if (!counter) { bitset_oom(); } counter->count = 0; size = (size_t)(size / BITSET_LITERAL_LENGTH) + 1; size_t pow2; BITSET_NEXT_POW2(pow2, size); counter->size = pow2; counter->words = bitset_calloc(1, counter->size * sizeof(bitset_word)); if (!counter->words) { bitset_oom(); } return counter; }