Skip to content

Commit e65e4f4

Browse files
authored
Update README.md
1 parent ecc8e06 commit e65e4f4

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

README.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -530,55 +530,55 @@ bitset_free(b); // frees memory
530530
More advanced example:
531531
532532
```C
533-
bitset_t *b = bitset_create();
534-
for (int k = 0; k < 1000; ++k) {
535-
bitset_set(b, 3 * k);
536-
}
537-
// We have bitset_count(b) == 1000.
538-
// We have bitset_get(b, 3) is true
539-
// You can iterate through the values:
540-
size_t k = 0;
541-
for (size_t i = 0; bitset_next_set_bit(b, &i); i++) {
542-
// You will have i == k
543-
k += 3;
544-
}
545-
// We support a wide range of operations on two bitsets such as
546-
// bitset_inplace_symmetric_difference(b1,b2);
547-
// bitset_inplace_symmetric_difference(b1,b2);
548-
// bitset_inplace_difference(b1,b2);// should make no difference
549-
// bitset_inplace_union(b1,b2);
550-
// bitset_inplace_intersection(b1,b2);
551-
// bitsets_disjoint
552-
// bitsets_intersect
533+
bitset_t *b = bitset_create();
534+
for (int k = 0; k < 1000; ++k) {
535+
bitset_set(b, 3 * k);
536+
}
537+
// We have bitset_count(b) == 1000.
538+
// We have bitset_get(b, 3) is true
539+
// You can iterate through the values:
540+
size_t k = 0;
541+
for (size_t i = 0; bitset_next_set_bit(b, &i); i++) {
542+
// You will have i == k
543+
k += 3;
544+
}
545+
// We support a wide range of operations on two bitsets such as
546+
// bitset_inplace_symmetric_difference(b1,b2);
547+
// bitset_inplace_symmetric_difference(b1,b2);
548+
// bitset_inplace_difference(b1,b2);// should make no difference
549+
// bitset_inplace_union(b1,b2);
550+
// bitset_inplace_intersection(b1,b2);
551+
// bitsets_disjoint
552+
// bitsets_intersect
553553
```
554554

555555
In some instances, you may want to convert a Roaring bitmap into a conventional (uncompressed) bitset.
556556
Indeed, bitsets have advantages such as higher query performances in some cases. The following code
557557
illustrates how you may do so:
558558

559559
```C
560-
roaring_bitmap_t *r1 = roaring_bitmap_create();
561-
for (uint32_t i = 100; i < 100000; i+= 1 + (i%5)) {
560+
roaring_bitmap_t *r1 = roaring_bitmap_create();
561+
for (uint32_t i = 100; i < 100000; i+= 1 + (i%5)) {
562562
roaring_bitmap_add(r1, i);
563-
}
564-
for (uint32_t i = 100000; i < 500000; i+= 100) {
563+
}
564+
for (uint32_t i = 100000; i < 500000; i+= 100) {
565565
roaring_bitmap_add(r1, i);
566-
}
567-
roaring_bitmap_add_range(r1, 500000, 600000);
568-
bitset_t * bitset = bitset_create();
569-
bool success = roaring_bitmap_to_bitset(r1, bitset);
570-
assert(success); // could fail due to memory allocation.
571-
assert(bitset_count(bitset) == roaring_bitmap_get_cardinality(r1));
572-
// You can then query the bitset:
573-
for (uint32_t i = 100; i < 100000; i+= 1 + (i%5)) {
574-
assert(bitset_get(bitset,i));
575-
}
576-
for (uint32_t i = 100000; i < 500000; i+= 100) {
577-
assert(bitset_get(bitset,i));
578-
}
579-
// you must free the memory:
580-
bitset_free(bitset);
581-
roaring_bitmap_free(r1);
566+
}
567+
roaring_bitmap_add_range(r1, 500000, 600000);
568+
bitset_t * bitset = bitset_create();
569+
bool success = roaring_bitmap_to_bitset(r1, bitset);
570+
assert(success); // could fail due to memory allocation.
571+
assert(bitset_count(bitset) == roaring_bitmap_get_cardinality(r1));
572+
// You can then query the bitset:
573+
for (uint32_t i = 100; i < 100000; i+= 1 + (i%5)) {
574+
assert(bitset_get(bitset,i));
575+
}
576+
for (uint32_t i = 100000; i < 500000; i+= 100) {
577+
assert(bitset_get(bitset,i));
578+
}
579+
// you must free the memory:
580+
bitset_free(bitset);
581+
roaring_bitmap_free(r1);
582582
```
583583
584584
You should be aware that a convention bitset (`bitset_t *`) may use much more

0 commit comments

Comments
 (0)