/* Brian O'Connor * bitmap.h * macros that facilitate treating a 32-bit int as a 32-bit bitmap. */ #include "bitmap.h" #include #include int TestBit(Bitmap b, int i) { assert(i < BITMAP_SIZE); return( b & (1 << i) ); } void SetBit(Bitmap& b, int i) { assert(i < BITMAP_SIZE); b = b | (1 << i); } void ClearBit(Bitmap& b, int i) { assert(i < BITMAP_SIZE); b = b & ( ~(1 << i) ); } int MapIsClear(Bitmap b) { return( b == 0); } void PrintBitmap(Bitmap b) { int i; for( i = BITMAP_SIZE - 1; i >= 0; i-- ) { if( b & (1 << i) ) { printf("1"); } else printf("0"); } printf("\n"); } Bitmap ZeroBitmap(void) { return( 0L ); }