| 1 |
/********************************************************************** |
| 2 |
* Copyright (C) 2002-2003 by Gezelter's Group
|
| 3 |
*This program is free software; you can redistribute it and/or modify
|
| 4 |
*it under the terms of the GNU General Public License as published by
|
| 5 |
*the Free Software Foundation version 2 of the License.
|
| 6 |
*
|
| 7 |
*This program is distributed in the hope that it will be useful,
|
| 8 |
*but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
*GNU General Public License for more details.
|
| 11 |
*
|
| 12 |
************************************************************************ |
| 13 |
*Author: Teng Lin Email: tlin@nd.edu |
| 14 |
*Date: 08/13/2002 Version: 1.0 |
| 15 |
* |
| 16 |
************************************************************************ |
| 17 |
*Description: |
| 18 |
* |
| 19 |
***********************************************************************/ |
| 20 |
#ifndef bitvectorH |
| 21 |
#define bitvectorH |
| 22 |
#include <iostream> |
| 23 |
#include <vector> |
| 24 |
|
| 25 |
using namespace std; |
| 26 |
|
| 27 |
class TBitVector : public bit_vector |
| 28 |
{ |
| 29 |
public: |
| 30 |
TBitVector(); |
| 31 |
TBitVector(int size); |
| 32 |
~TBitVector(); |
| 33 |
|
| 34 |
void Resize(); |
| 35 |
bool IsEmpty(); |
| 36 |
|
| 37 |
void SetBitOn(int index); |
| 38 |
void SetBitOff(int index); |
| 39 |
void SetRangeOn(int begin, int end); |
| 40 |
void SetRangeOff(int begin, int end); |
| 41 |
void SetAllOn(); |
| 42 |
void SetAllOff(); |
| 43 |
|
| 44 |
bool IsBitOn(int index); |
| 45 |
|
| 46 |
TBitVector& operator =(const TBitVector &src); |
| 47 |
TBitVector& operator &=(const TBitVector &src); |
| 48 |
TBitVector& operator |=(const TBitVector &src); |
| 49 |
TBitVector& operator ^=(const TBitVector &src); |
| 50 |
TBitVector& operator -=(const TBitVector &src); |
| 51 |
TBitVector& operator |=(const int i); |
| 52 |
|
| 53 |
bool operator[](const int i); |
| 54 |
|
| 55 |
void FromIntVec(vector<int> &intVec); |
| 56 |
void ToIntvec(vector<int> &intVec); |
| 57 |
|
| 58 |
friend TBitVector operator &(const TBitVector& bv1, const TBitVector& bv2); |
| 59 |
friend TBitVector operator |(const TBitVector& bv1, const TBitVector& bv2); |
| 60 |
friend TBitVector operator ^(const TBitVector& bv1, const TBitVector& bv2); |
| 61 |
friend TBitVector operator -(const TBitVector& bv1, const TBitVector& bv2); |
| 62 |
friend bool operator ==(const TBitVector& bv1, const TBitVector& bv2); |
| 63 |
|
| 64 |
}; |
| 65 |
//--------------------------------------------------------------------------- |
| 66 |
#endif |