1 | /**********************************************************************
|
---|
2 | *<
|
---|
3 | FILE: bitarray.h
|
---|
4 |
|
---|
5 | DESCRIPTION:
|
---|
6 |
|
---|
7 | CREATED BY: Dan Silva
|
---|
8 |
|
---|
9 | HISTORY:
|
---|
10 |
|
---|
11 | *> Copyright (c) 1994, All Rights Reserved.
|
---|
12 | **********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef BITARRAY__H
|
---|
15 | #define BITARRAY__H
|
---|
16 |
|
---|
17 | #include <windef.h>
|
---|
18 | #include <ioapi.h>
|
---|
19 |
|
---|
20 | class BitArray {
|
---|
21 | DWORD* bits;
|
---|
22 | long numBits;
|
---|
23 | public:
|
---|
24 | DllExport void SetSize(int n, int save=0); // save=1:preserve old bit values
|
---|
25 | int GetSize() const { return numBits; }
|
---|
26 | DllExport void ClearAll();
|
---|
27 | DllExport void SetAll();
|
---|
28 | DllExport void Set(int i); // set ith bit to 1
|
---|
29 | DllExport void Clear(int i); // set ith bit to 0
|
---|
30 | DllExport void Set(int i, int b); // set ith bit to b
|
---|
31 | DllExport int operator[](int i) const; // get ith bit
|
---|
32 | DllExport int NumberSet(); // how many bits are 1's.
|
---|
33 | DllExport void Compress();
|
---|
34 | DllExport void Expand();
|
---|
35 | DllExport IOResult Save(ISave* isave);
|
---|
36 | DllExport IOResult Load(ILoad* iload);
|
---|
37 |
|
---|
38 | BitArray() { bits = NULL; numBits = 0; }
|
---|
39 | DllExport BitArray(int n);
|
---|
40 | DllExport BitArray(const BitArray& b);
|
---|
41 | DllExport ~BitArray();
|
---|
42 |
|
---|
43 | DllExport BitArray& operator=(const BitArray& b);
|
---|
44 |
|
---|
45 | // Assignment operators: These require arrays of the same size!
|
---|
46 | DllExport BitArray& operator&=(const BitArray& b); // AND=
|
---|
47 | DllExport BitArray& operator|=(const BitArray& b); // OR=
|
---|
48 | DllExport BitArray& operator^=(const BitArray& b); // XOR=
|
---|
49 |
|
---|
50 | // Binary operators: These require arrays of the same size!
|
---|
51 | DllExport BitArray operator&(const BitArray&) const; // AND
|
---|
52 | DllExport BitArray operator|(const BitArray&) const; // OR
|
---|
53 | DllExport BitArray operator^(const BitArray&) const; // XOR
|
---|
54 |
|
---|
55 | // Unary operators
|
---|
56 | DllExport BitArray operator~(); // unary NOT function
|
---|
57 |
|
---|
58 | };
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 | #endif
|
---|