diff options
author | Luca Deri <deri@ntop.org> | 2021-09-27 12:06:46 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2021-09-27 12:06:46 +0200 |
commit | 241ee32cbc283360fe7882b5d8f8dde1d3ed2640 (patch) | |
tree | 878462b5d96b04b739d69eccab69350e6156124a | |
parent | 519c69c5cc1d70d06707cc53e048fd3fe8079550 (diff) |
Bitmap code
-rw-r--r-- | src/lib/ndpi_bitmap.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/ndpi_bitmap.c b/src/lib/ndpi_bitmap.c index 7e5a0dbf9..ecb238da7 100644 --- a/src/lib/ndpi_bitmap.c +++ b/src/lib/ndpi_bitmap.c @@ -99,3 +99,48 @@ size_t ndpi_bitmap_serialize(ndpi_bitmap* b, char **buf) { ndpi_bitmap* ndpi_bitmap_deserialize(char *buf) { return((ndpi_bitmap*)roaring_bitmap_deserialize(buf)); } + +/* ******************************************* */ + +/* b = b & b_and */ +void ndpi_bitmap_and(ndpi_bitmap* b, ndpi_bitmap* b_and) { + roaring_bitmap_and_inplace((ndpi_bitmap*)a, (ndpi_bitmap*)b_and); +} + +/* ******************************************* */ + +/* b = b | b_or */ +void ndpi_bitmap_or(ndpi_bitmap* a, ndpi_bitmap* b_or) { + roaring_bitmap_or_inplace((ndpi_bitmap*)a, (ndpi_bitmap*)b_or); +} + +/* ******************************************* */ + +/* b = b | b_or */ +void ndpi_bitmap_or(ndpi_bitmap* a, ndpi_bitmap* b_or) { + roaring_bitmap_or_inplace((ndpi_bitmap*)a, (ndpi_bitmap*)b_or); +} + +/* ******************************************* */ + +ndpi_bitmap_iterator* ndpi_bitmap_iterator_alloc(ndpi_bitmap* b) { + return(roaring_create_iterator((ndpi_bitmap*)b)); +} + +/* ******************************************* */ + +ndpi_bitmap_iterator* ndpi_bitmap_iterator_free(ndpi_bitmap* b) { + return(roaring_free_uint32_iterator((ndpi_bitmap*)b)); +} + +/* ******************************************* */ + +/* Return the next value in the bitmap iterator + + true is returned when a value is present, false when we reached the end +*/ +bool ndpi_bitmap_iterator_next(ndpi_bitmap_iterator* i, uint32_t *value) { + uint32_t num = roaring_read_uint32_iterator((roaring_uint32_iterator_t*)i, value, 1); + + return((num == 1) ? true /* found */ : false /* not found */); +} |