/***************************************************************
 * PrBitmap.h
 *
 * This class provides a bitmap interface.
 *
 ****************************************************************/

/*
 * modification history
 *----------------------
 *
 * 02/18/97: K.C. Chang: created.
 */

#ifndef _PrBitmap_h
#define _PrBitmap_h

#include "PrGlobalDefn.h"


class PrBitmap {
  public:
    PrBitmap(int numBits);
    ~PrBitmap();
    
    void set(int n);   	        // Set the "nth" bit
    void clear(int n);  	// Clear the "nth" bit
    int test(int n) const;	// Is the "nth" bit set?
    int findAndSet();           // Return the # of a clear bit, and as a side
				// effect, set the bit. 
				// If no bits are clear, return -1.
    int numClear() const;	// Return the number of clear bits

    void display() const;	// Print contents of bitmap
    void selfTest();		// selfTest whether bitmap is working
    
  private:
    int numBits_;		// number of bits in the bitmap
    int bitsPerWord_;

    unsigned int *map_;

    // Copy is not allowed.
    PrBitmap(const PrBitmap &) {}
    PrBitmap &operator= (const PrBitmap &) { return *this; }
};

#endif // _PrBitmap_h
