/* bitvect.ha8
Apr 19 2001
Chris Lacher
BitVector class - based on array of 8-bit words
01/13/07: style upgrade
Copyright 2001 - 2007, R.C. Lacher
*/
#ifndef _BITVECT_H
#define _BITVECT_H
#include <stdlib.h>
#include <xstring.h>
namespace fsu
{
//----------------------------------
// BitVector
//----------------------------------
class BitVector;
std::ostream& operator << (std::ostream&, const BitVector&);
class BitVector
{
public:
explicit BitVector (unsigned int size); // construct a BitVector with specified size
BitVector (const BitVector&); // copy constructor
~BitVector (); // destructor
BitVector& operator = (const BitVector& a); // assignment operator
unsigned int Size () const; // return size of bitvector
void Set (); // make all bits = 1
void Set (unsigned int index); // make bit = 1
void Unset (); // make all bits = 0
void Unset (unsigned int index); // make bit = 0
void Flip (); // change all bits
void Flip (unsigned int index); // change bit
int Test (unsigned int index) const; // return bit value
private:
// data
unsigned char * byteArray_;
size_t byteArraySize_;
// methods
size_t ByteNumber (unsigned int index) const;
static unsigned char Mask (unsigned int index);
} ; // class BitBector
} // namespace fsu
#endif