bitmap.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef SATSOLVER_BITMAP_H
00014 #define SATSOLVER_BITMAP_H
00015
00016 #include <string.h>
00017
00018 typedef struct _Map {
00019 unsigned char *map;
00020 int size;
00021 } Map;
00022
00023 #define MAPZERO(m) (memset((m)->map, 0, (m)->size))
00024
00025 #define MAPSET(m, n) ((m)->map[(n) >> 3] |= 1 << ((n) & 7))
00026
00027 #define MAPCLR(m, n) ((m)->map[(n) >> 3] &= ~(1 << ((n) & 7)))
00028
00029 #define MAPTST(m, n) ((m)->map[(n) >> 3] & (1 << ((n) & 7)))
00030
00031 extern void map_init(Map *m, int n);
00032 extern void map_init_clone(Map *t, Map *s);
00033 extern void map_grow(Map *m, int n);
00034 extern void map_free(Map *m);
00035
00036 static inline void map_empty(Map *m)
00037 {
00038 MAPZERO(m);
00039 }
00040 static inline void map_set(Map *m, int n)
00041 {
00042 MAPSET(m, n);
00043 }
00044 static inline void map_clr(Map *m, int n)
00045 {
00046 MAPCLR(m, n);
00047 }
00048 static inline int map_tst(Map *m, int n)
00049 {
00050 return MAPTST(m, n);
00051 }
00052
00053 #endif