1 #define PERL_NO_GET_CONTEXT
13 bit* bit_create(IV len) {
15 croak("Length less than 1");
22 Newxz(ret->t, len, IV);
26 void bit_free(bit *b) {
31 IV bit_query(bit *b, IV idx) {
32 if(idx > b->n || idx < 1){
33 croak("Index not in range [1," IVdf "]", b->n);
38 ret += b->t[idx], idx -= idx & -idx;
42 void bit_update(bit *b, IV idx, IV value) {
43 if(idx > b->n || idx < 1){
44 croak("Index not in range [1," IVdf "]", b->n);
48 b->t[idx] += value, idx += idx & -idx;
51 void bit_clear(bit *b) {
55 typedef bit *Algorithm__BIT__XS;
57 MODULE = Algorithm::BIT::XS PACKAGE = Algorithm::BIT::XS PREFIX = bit_
61 Algorithm::BIT::XS bit_create(IV len);
63 void bit_free(Algorithm::BIT::XS b);
65 IV bit_query(Algorithm::BIT::XS b, IV idx);
67 void bit_update(Algorithm::BIT::XS b, IV idx, IV value);
69 void bit_clear(Algorithm::BIT::XS b);