예제 #1
0
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;
}
예제 #2
0
파일: vector.c 프로젝트: chriso/bitset
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;
}
예제 #3
0
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;
}
예제 #4
0
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;
}