7 #ifndef __data_DynamicBitset_h__ 8 #define __data_DynamicBitset_h__ 11 #ifdef FE_BOOST_BITSET 12 #include "boost/dynamic_bitset.hpp" 13 typedef boost::dynamic_bitset<> t_bitset;
17 class VeryCrudeDynamicBitset
21 VeryCrudeDynamicBitset(
void) {}
23 VeryCrudeDynamicBitset(
size_t a_size)
26 for(
unsigned int i = 0 ; i < m_vec.size(); i++)
32 bool is_subset_of(
const VeryCrudeDynamicBitset &a_bitset)
const 34 unsigned int other_size_minus_one =
35 (
unsigned int)(a_bitset.m_vec.size()-1);
36 for(
unsigned int i = 0 ; i < m_vec.size(); i++)
40 if(i > other_size_minus_one) {
return false; }
41 if(!a_bitset.m_vec[i]) {
return false; }
47 bool operator==(
const VeryCrudeDynamicBitset &a_bitset)
const 49 if(m_vec.size() != a_bitset.m_vec.size())
53 for(
unsigned int i = 0 ; i < m_vec.size(); i++)
55 if(m_vec != a_bitset.m_vec)
62 bool operator<(
const VeryCrudeDynamicBitset &a_bitset)
const 64 if(m_vec.size() < a_bitset.m_vec.size())
68 if(m_vec.size() > a_bitset.m_vec.size())
72 for(
unsigned int i = 0 ; i < m_vec.size(); i++)
74 if(m_vec > a_bitset.m_vec)
78 if(m_vec < a_bitset.m_vec)
85 void resize(
unsigned int a_size)
90 void set(
unsigned int a_index)
92 m_vec[a_index] = U8(
true);
95 bool operator [] (
unsigned int a_index)
const 97 return bool(m_vec[a_index]) ==
true;
100 VeryCrudeDynamicBitset
101 operator & (
const VeryCrudeDynamicBitset &a_other)
const 103 VeryCrudeDynamicBitset result(m_vec.size());
104 for(
unsigned int i = 0; i < m_vec.size(); i++)
106 if(a_other.m_vec[i] && m_vec[i])
108 result.m_vec[i] =
true;
112 result.m_vec[i] =
false;
118 VeryCrudeDynamicBitset
119 operator | (
const VeryCrudeDynamicBitset &a_other)
const 121 VeryCrudeDynamicBitset result(m_vec.size());
122 for(
unsigned int i = 0; i < m_vec.size(); i++)
124 if(a_other.m_vec[i] || m_vec[i])
126 result.m_vec[i] =
true;
130 result.m_vec[i] =
false;
136 unsigned int size(
void)
const {
return m_vec.size(); }
140 std::vector<U8> m_vec;
143 typedef VeryCrudeDynamicBitset t_bitset;
146 inline bool partial_is_subset(
const t_bitset &a_sub,
const t_bitset &a_set)
148 if(a_sub.size() != a_set.size())
150 t_bitset a_fit = a_sub;
151 a_fit.resize(a_set.size());
152 return a_fit.is_subset_of(a_set);
154 return a_sub.is_subset_of(a_set);