Mercurial > ~dholland > hg > ag > index.cgi
diff anagram/support/bitmap.h @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/anagram/support/bitmap.h Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,58 @@ +/* + * AnaGram, A System for Syntax Directed Programming + * Copyright 1993-2000 Parsifal Software. All Rights Reserved. + * See the file COPYING for license and usage terms. + * + * bitmap.h + */ + +#ifndef BITMAP_H +#define BITMAP_H + +#include <string.h> +#include "port.h" + +#include "data.h" // sigh... XXX (for n_chars) +#include "pointer.h" + + +class Bitmap { +protected: + unsigned nChars; + unsigned int nBits; + + ArrayPointer<unsigned char> map; + +public: + Bitmap(int n) : nChars((n+7)/8), nBits(n), map(new unsigned char[nChars]) { + memset(map, 0, nChars); + } + virtual ~Bitmap() {} + virtual int setBit(int x); + virtual int getBit(int x); + virtual int list(int *x); + virtual Bitmap &setRange(unsigned first, unsigned last); + Bitmap &operator |= (const Bitmap &b); + Bitmap &operator &= (const Bitmap &b); + Bitmap &operator -= (const Bitmap &b); + Bitmap &operator ~ (); +}; + +class CharBitmap : public Bitmap { +public: + CharBitmap() : Bitmap(n_chars) {} + CharBitmap(const Bitmap &b) : Bitmap(b) {} + virtual int setBit(int x); + virtual int getBit(int x); + virtual int list(int *x); +#ifdef _MSC_VER + virtual Bitmap &setRange(unsigned first, unsigned last); +#else + virtual CharBitmap &setRange(unsigned first, unsigned last); +#endif + void blurCase(); + void blurCase(int); +}; + + +#endif /* BITMAP_H */