00001 // bbq - Copyright (C) 2005, Axel Mosig, University of Leipzig. See 00002 // main.cpp for details. 00003 00004 #ifndef BITSET_H 00005 #define BITSET_H 00006 00007 #include <iostream> 00008 00009 namespace bbq { 00010 00018 class uint_bitset 00019 { 00020 private: 00021 00022 unsigned int bits; 00023 00024 public: 00025 00026 // k corresponds to the number of bits and hence the number of 00027 // sequence fragments in footprint_detector. In uint64_bitset, 00028 // this variable only exists for formal reasons and does not have 00029 // an influence on the number of bits, which is fixed to 00030 // 8*sizeof(unsigned int), which is usually 32. 00031 static int k; 00032 00033 uint_bitset() 00034 { 00035 bits = 0; 00036 } 00037 00039 bool subseteq(const uint_bitset&); 00040 00048 bool operator<(const uint_bitset&); 00049 00057 bool operator==(const uint_bitset&); 00058 00059 // this version of subseteq checks only up to the J-th bit whether 00060 // *this is a subset of the set passed as an argument. 00061 bool subseteq(const uint_bitset&, const unsigned int& J); 00062 00064 int cardinality(); 00065 00066 friend std::ostream& operator<<(std::ostream& o,const uint_bitset&); 00067 00069 void intersect(const uint_bitset& b); 00070 00073 void set(const int& j); 00074 00078 void remove(const int& j); 00079 00080 }; 00081 00090 class uint64_bitset 00091 { 00092 private: 00093 00094 unsigned long long bits; 00095 00096 public: 00097 00098 // k corresponds to the number of bits and hence the number of 00099 // sequence fragments in footprint_detector. In uint64_bitset, 00100 // this variable only exists for formal reasons and does not have 00101 // an influence on the number of bits, which is fixed to 00102 // 8*sizeof(unsigned long long), which is usually 64. 00103 static int k; 00104 00105 uint64_bitset() 00106 { 00107 bits = 0; 00108 } 00109 00110 bool subseteq(const uint64_bitset&); 00111 00119 bool operator<(const uint64_bitset&) const; 00120 00128 bool operator==(const uint64_bitset&) const; 00129 00130 int cardinality(); 00131 00132 friend std::ostream& operator<<(std::ostream& o,const uint64_bitset&); 00133 00134 void intersect(const uint64_bitset& b); 00135 00136 void set(const int& j); 00137 00138 void remove(const int& j); 00139 00140 }; 00141 00150 class variable_bitset 00151 { 00152 private: 00153 00154 unsigned int* bits; 00155 00156 public: 00157 00158 // k corresponds to the number of bits and hence the number of 00159 // sequence fragments in footprint_detector 00160 static int k; 00161 00163 variable_bitset(const variable_bitset&); 00164 00166 variable_bitset& operator=(const variable_bitset& vb); 00167 00169 variable_bitset(); 00170 00172 ~variable_bitset() 00173 { 00174 delete[] bits; 00175 } 00176 00177 bool subseteq(const variable_bitset&) const; 00178 00180 int cardinality(); 00181 00182 friend std::ostream& operator<<(std::ostream& o,const variable_bitset&); 00183 00184 void intersect(const variable_bitset& b); 00185 00186 void set(const int& j); 00187 00188 void remove(const int& j); 00189 00197 bool operator<(const variable_bitset&); 00198 00206 bool operator==(const variable_bitset&); 00207 00208 }; 00209 00210 00211 } // end namespace bbq 00212 00213 #endif 00214