9 #ifndef _STRUS_DYNAMIC_BITSET_HPP_INCLUDED
10 #define _STRUS_DYNAMIC_BITSET_HPP_INCLUDED
15 #define STRUS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
18 #undef STRUS_USE_STD_DYNAMIC_BITSET
19 #if __cplusplus >= 201103L
21 #define STRUS_USE_STD_DYNAMIC_BITSET
22 #elif defined __GNUC__
23 #if STRUS_GCC_VERSION >= 40900
24 #define STRUS_USE_STD_DYNAMIC_BITSET
25 #endif // STRUS_GCC_VERSION
29 #ifdef STRUS_USE_STD_DYNAMIC_BITSET
40 :m_indices( (size_+(ElementDim-1)) / ElementDim, -1),m_elements(){}
42 :m_indices(o.m_indices),m_elements(o.m_elements){}
43 void set( std::size_t n,
bool val =
true)
45 int hi = n / ElementDim;
46 int li = n % ElementDim;
47 int idx = m_indices[ hi];
50 idx = m_indices[ hi] = m_elements.size();
51 m_elements.push_back( bitset<ElementDim>());
53 m_elements[ idx].set( li, val);
55 bool test( std::size_t n)
const
57 int hi = n / ElementDim;
58 int li = n % ElementDim;
59 int idx = m_indices[ hi];
60 if (idx == -1)
return false;
61 return m_elements.at(idx).test( li);
66 std::fill( m_indices.begin(), m_indices.end(), -1);
70 enum {ElementDim=256};
71 std::vector<int> m_indices;
72 std::vector<bitset<ElementDim> > m_elements;
76 #else //STRUS_USE_STD_DYNAMIC_BITSET
77 #include <boost/dynamic_bitset.hpp>
82 :
public boost::dynamic_bitset<>
92 #endif //STRUS_USE_STD_DYNAMIC_BITSET
dynamic_bitset(const dynamic_bitset &o)
Definition: dynamic_bitset.hpp:87
dynamic_bitset(std::size_t size_)
Definition: dynamic_bitset.hpp:85
Definition: dynamic_bitset.hpp:81