00001 // bbq - Copyright (C) 2005, Axel Mosig, University of Leipzig. See 00002 // main.cpp for details. 00003 00004 #ifndef WEIGHTED_BITMULTISETS_H 00005 #define WEIGHTED_BITMULTISETS_H 00006 00007 #include <iostream> 00008 00009 00010 namespace bbq { 00011 00018 class weighted_bit_multi_set 00019 { 00020 public: 00021 00022 typedef unsigned char c_uint; 00023 00024 c_uint* counts; 00025 00028 static int k; 00029 00031 static bool weighted; 00032 static int k_; 00033 float* weights; 00034 00036 weighted_bit_multi_set(const weighted_bit_multi_set&); 00037 00039 weighted_bit_multi_set& operator=(const weighted_bit_multi_set& vb); 00040 00042 weighted_bit_multi_set(); 00043 00045 ~weighted_bit_multi_set() 00046 { 00047 delete[] counts; 00048 } 00049 00050 bool subseteq(const weighted_bit_multi_set&) const; 00051 00052 // this version of subseteq checks only up to the J-th bit whether 00053 // *this is a subset of the set passed as an argument. 00054 bool subseteq(const weighted_bit_multi_set&, const unsigned int& J) const; 00055 00063 bool operator<(const weighted_bit_multi_set&) const; 00064 00072 bool operator==(const weighted_bit_multi_set&) const; 00073 00075 int cardinality(); 00076 00079 float weight(); 00080 00081 friend std::ostream& operator<<(std::ostream& o,const weighted_bit_multi_set&); 00082 00084 void intersect(const weighted_bit_multi_set& b); 00085 00088 void set(const int& j, const float& w); 00089 00091 void reset(const int& j, const float& w); 00092 00094 void decrease(const int& j, const float& w); 00095 00099 void remove(const int& j, const float& w); 00100 00103 bool contains(const int&); 00104 00105 }; 00106 00107 } // end namespace bbq 00108 00109 00110 #endif 00111