bitmap: implement map_and and MAPSETALL
authorAles Kozumplik <akozumpl@redhat.com>
Fri, 20 Jan 2012 09:51:05 +0000 (10:51 +0100)
committerAles Kozumplik <akozumpl@redhat.com>
Fri, 9 Mar 2012 10:02:51 +0000 (11:02 +0100)
src/bitmap.c
src/bitmap.h
src/libsolv.ver

index d57971d..94a88ca 100644 (file)
@@ -59,4 +59,16 @@ map_grow(Map *m, int n)
     }
 }
 
+/* bitwise-ands same-sized maps t and s, stores the result in t. */
+void
+map_and(Map *t, Map *s)
+{
+    unsigned char *ti, *si, *end;
+    ti = t->map;
+    si = s->map;
+    end = ti + t->size;
+    while (ti < end)
+       *ti++ &= *si++;
+}
+
 /* EOF */
index b931d7e..3bad3c3 100644 (file)
@@ -21,6 +21,8 @@ typedef struct _Map {
 } Map;
 
 #define MAPZERO(m) (memset((m)->map, 0, (m)->size))
+/* set all bits */
+#define MAPSETALL(m) (memset((m)->map, 0xff, (m)->size))
 /* set bit */
 #define MAPSET(m, n) ((m)->map[(n) >> 3] |= 1 << ((n) & 7))
 /* clear bit */
@@ -32,6 +34,7 @@ extern void map_init(Map *m, int n);
 extern void map_init_clone(Map *t, Map *s);
 extern void map_grow(Map *m, int n);
 extern void map_free(Map *m);
+extern void map_and(Map *t, Map *s);
 
 static inline void map_empty(Map *m)
 {
index fcb95b3..5204e29 100644 (file)
@@ -26,6 +26,7 @@ SOLV_1.0 {
                dirpool_free;
                dirpool_init;
                dirpool_make_dirtraverse;
+               map_and;
                map_free;
                map_grow;
                map_init;