home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / BitSet.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-06  |  562 b   |  33 lines

  1. #include "BitSet.h"
  2.  
  3. #include <string.h>
  4.  
  5. BitSet::BitSet(unsigned int size){
  6.     numBytes = (size>>3) + 1;
  7.     bytes=new unsigned char[numBytes];
  8. }
  9.  
  10. BitSet::~BitSet(){
  11.     delete bytes;
  12. }
  13.  
  14. void BitSet::clear(unsigned int n){
  15.     bytes[n>>3] &= ~(0x01<<(n&0x07));
  16. }
  17.  
  18. void BitSet::clearAll(){
  19.     memset(bytes, 0x00, numBytes);
  20. }
  21.  
  22. void BitSet::set(unsigned int n){
  23.     bytes[n>>3] |= (0x01<<(n&0x07));
  24. }
  25.  
  26. void BitSet::setAll(){
  27.     memset(bytes, 0xFF, numBytes);
  28. }
  29.  
  30. bool BitSet::isSet(unsigned int n){
  31.     return ( bytes[n>>3] & (0x01<<(n&0x07)) ) != 0;
  32. }
  33.