summaryrefslogtreecommitdiff
path: root/src/basic/bitmap.h
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-07-16 14:06:11 +0200
committerTom Gundersen <teg@jklm.no>2015-07-16 14:11:12 +0200
commitcb57dd41595adddb08095298bb1ed258c8ea4877 (patch)
tree6478f1aa84a405218ab50bc3508b1c39d0de20e2 /src/basic/bitmap.h
parent443a55981388f519fb6528a8ee042f9e69079b68 (diff)
downloadsystemd-cb57dd41595adddb08095298bb1ed258c8ea4877.tar.gz
systemd-cb57dd41595adddb08095298bb1ed258c8ea4877.tar.bz2
systemd-cb57dd41595adddb08095298bb1ed258c8ea4877.zip
bitmap: use external iterator
Reuse the Iterator object from hashmap.h and expose a similar API. This allows us to do { Iterator i; unsigned n; BITMAP_FOREACH(n, b, i) { Iterator j; unsigned m; BITMAP_FOREACH(m, b, j) { ... } } } without getting confused. Requested by David.
Diffstat (limited to 'src/basic/bitmap.h')
-rw-r--r--src/basic/bitmap.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/basic/bitmap.h b/src/basic/bitmap.h
index 92bee51a2c..2874bc99f7 100644
--- a/src/basic/bitmap.h
+++ b/src/basic/bitmap.h
@@ -22,6 +22,7 @@
***/
#include "macro.h"
+#include "hashmap.h"
typedef struct Bitmap Bitmap;
@@ -37,13 +38,12 @@ bool bitmap_isset(Bitmap *b, unsigned n);
bool bitmap_isclear(Bitmap *b);
void bitmap_clear(Bitmap *b);
-void bitmap_rewind(Bitmap *b);
-bool bitmap_next(Bitmap *b, unsigned *n);
+bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
bool bitmap_equal(Bitmap *a, Bitmap *b);
-#define BITMAP_FOREACH(n, b) \
- for (bitmap_rewind(b); bitmap_next((b), &(n)); )
+#define BITMAP_FOREACH(n, b, i) \
+ for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); )
DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free);