comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 /*
2 * AnaGram, A System for Syntax Directed Programming
3 * Copyright 1993-2000 Parsifal Software. All Rights Reserved.
4 * See the file COPYING for license and usage terms.
5 *
6 * bitmap.h
7 */
8
9 #ifndef BITMAP_H
10 #define BITMAP_H
11
12 #include <string.h>
13 #include "port.h"
14
15 #include "data.h" // sigh... XXX (for n_chars)
16 #include "pointer.h"
17
18
19 class Bitmap {
20 protected:
21 unsigned nChars;
22 unsigned int nBits;
23
24 ArrayPointer<unsigned char> map;
25
26 public:
27 Bitmap(int n) : nChars((n+7)/8), nBits(n), map(new unsigned char[nChars]) {
28 memset(map, 0, nChars);
29 }
30 virtual ~Bitmap() {}
31 virtual int setBit(int x);
32 virtual int getBit(int x);
33 virtual int list(int *x);
34 virtual Bitmap &setRange(unsigned first, unsigned last);
35 Bitmap &operator |= (const Bitmap &b);
36 Bitmap &operator &= (const Bitmap &b);
37 Bitmap &operator -= (const Bitmap &b);
38 Bitmap &operator ~ ();
39 };
40
41 class CharBitmap : public Bitmap {
42 public:
43 CharBitmap() : Bitmap(n_chars) {}
44 CharBitmap(const Bitmap &b) : Bitmap(b) {}
45 virtual int setBit(int x);
46 virtual int getBit(int x);
47 virtual int list(int *x);
48 #ifdef _MSC_VER
49 virtual Bitmap &setRange(unsigned first, unsigned last);
50 #else
51 virtual CharBitmap &setRange(unsigned first, unsigned last);
52 #endif
53 void blurCase();
54 void blurCase(int);
55 };
56
57
58 #endif /* BITMAP_H */