1 // -*- mode: cpp; mode: fold -*-
3 // $Id: bitmap.h,v 1.1 1999/11/05 05:47:06 jgg Exp $
4 /* ######################################################################
6 Bitmap - A trivial class to implement an 1 bit per element boolean
9 This is deliberately extremely light weight so that it is fast for
12 ##################################################################### */
18 #pragma interface "dsync/bitmap.h"
26 #define BITMAPVECTOR_SIZE sizeof(unsigned long)*8
28 // Compute the necessary size of the vector in bytes.
29 inline unsigned Bytes() {return (Size + BITMAPVECTOR_SIZE - 1)/BITMAPVECTOR_SIZE;};
33 inline void Set(unsigned long Elm)
34 {Vect[Elm/BITMAPVECTOR_SIZE] |= 1 << (Elm%BITMAPVECTOR_SIZE);};
35 inline bool Get(unsigned long Elm)
36 {return (Vect[Elm/BITMAPVECTOR_SIZE] & (1 << (Elm%BITMAPVECTOR_SIZE))) != 0;};
37 inline void Set(unsigned long Elm,bool To)
40 Vect[Elm/BITMAPVECTOR_SIZE] |= 1 << (Elm%BITMAPVECTOR_SIZE);
42 Vect[Elm/BITMAPVECTOR_SIZE] &= ~(1 << (Elm%BITMAPVECTOR_SIZE));
45 BitmapVector(unsigned long Size);