tac0S
Template Affectional Command Operating System
bitmap.h
Go to the documentation of this file.
1 
18 #ifndef BITMAP_H
19 #define BITMAP_H
20 
21 #include "copyright.h"
22 #include "utility.h"
23 #include "openfile.h"
24 
26 #define BitsInByte 8
27 #define BitsInWord 32
28 
36 class BitMap
37 {
38  public:
40  BitMap (int nitems);
41 
43  ~BitMap (); // De-allocate bitmap
44 
46  void Mark (int which);
47 
49  void Clear (int which);
50 
52  bool Test (int which);
53 
55  int Find ();
56  // effect, set the bit.
57  // If no bits are clear, return -1.
58 
60  int NumClear ();
62  void Print ();
63 
64  // These aren't needed until FILESYS, when we will need to read and
65  // write the bitmap to a file
67  void FetchFrom (OpenFile * file);
68 
70  void WriteBack (OpenFile * file);
71 
72  private:
74  int numBits;
76  int numWords;
80  unsigned int *map; // bit storage
81 };
82 
83 #endif // BITMAP_H
void WriteBack(OpenFile *file)
write contents to disk
Definition: bitmap.cc:169
bool Test(int which)
Is the "nth" bit set?
Definition: bitmap.cc:82
void FetchFrom(OpenFile *file)
fetch contents from disk
Definition: bitmap.cc:156
void Mark(int which)
Set the "nth" bit.
Definition: bitmap.cc:54
void Print()
Print contents of bitmap.
Definition: bitmap.cc:139
~BitMap()
initially, all bits are cleared.
Definition: bitmap.cc:38
Data structures for opening, closing, reading and writing.
void Clear(int which)
Clear the "nth" bit.
Definition: bitmap.cc:68
int NumClear()
Return the number of clear bits.
Definition: bitmap.cc:120
The following class defines a "bitmap" – an array of bits, each of which can be independently set...
Definition: bitmap.h:36
Definition: openfile.h:77
Miscellaneous useful definitions, including debugging routines.
BitMap(int nitems)
Initialize a bitmap, with "nitems" bits.
Definition: bitmap.cc:24
int Find()
Return the # of a clear bit, and as a side.
Definition: bitmap.cc:102