10 #ifndef _STRUS_BITSET_HPP_INCLUDED 
   11 #define _STRUS_BITSET_HPP_INCLUDED 
   21         static uint64_t 
mask( uint64_t hi)      {
return hi & (((uint64_t)1 << (SIZE % 64)) -1);}
 
   26         static uint64_t 
mask( uint64_t hi)      {
return hi;}
 
   37                 for (; ii<ArSize; ++ii)
 
   45                 for (; ii<ArSize; ++ii)
 
   47                         m_ar[ ii] = o.m_ar[ ii];
 
   51         bool set( 
int pos, 
bool value)
 
   53                 if ((
unsigned int)pos >= SIZE) 
return false;
 
   54                 int idx = (
unsigned int)pos / 64;
 
   55                 int ofs = (
unsigned int)pos % 64;
 
   58                         m_ar[ idx] |= ((uint64_t)1 << ofs);
 
   62                         m_ar[ idx] &= ~((uint64_t)1 << ofs);
 
   69                 if ((
unsigned int)pos >= SIZE) 
return false;
 
   70                 int idx = (
unsigned int)pos / 64;
 
   71                 int ofs = (
unsigned int)pos % 64;
 
   72                 return (m_ar[ idx] & ((uint64_t)1 << ofs)) != 0;
 
   77                 if ((
unsigned int)pos >= SIZE) 
return false;
 
   78                 unsigned int idx = (
unsigned int)pos / 64;
 
   79                 unsigned int ofs = (
unsigned int)pos % 64;
 
   80                 unsigned int ii = ArSize-1;
 
   81                 for (; ii > idx; --ii)
 
   85                                 m_ar[ ii+1] |= (m_ar[ ii] & ((uint64_t)1UL << 63)) >> 63;
 
   91                         m_ar[ ii+1] |= (m_ar[ ii] & ((uint64_t)1UL << 63)) >> 63;
 
   93                 uint64_t left( m_ar[ idx]);
 
   94                 uint64_t right( left);
 
   95                 uint64_t newbit = ((uint64_t)value << ofs);
 
  101                 m_ar[ idx] = left | right;
 
  109         bool remove( 
int pos)
 
  111                 if ((
unsigned int)pos >= SIZE) 
return false;
 
  112                 unsigned int idx = (
unsigned int)pos / 64;
 
  113                 unsigned int ofs = (
unsigned int)pos % 64;
 
  115                 unsigned int ii = ArSize-1;
 
  116                 for (; ii > idx; --ii)
 
  118                         uint64_t lobit = m_ar[ ii] & 1;
 
  126                         m_ar[ idx] &= ~((uint64_t)1 << 63);
 
  131                         uint64_t left( m_ar[ idx]);
 
  132                         uint64_t delbit = left & ((uint64_t)1 << ofs);
 
  133                         uint64_t right( left ^ delbit);
 
  139                         m_ar[ ii] = left | right;
 
  147                 for (; ai < ArSize; ++ai) m_ar[ai] = 0;
 
  153                 int idx = (
unsigned int)pos / 64;
 
  154                 int ofs = (
unsigned int)pos % 64;
 
  155                 if (idx >= ArSize) 
return -1;
 
  156                 uint64_t start = m_ar[ idx];
 
  157                 start &= ~((((uint64_t)1) << ofs) - 1);
 
  161                         return idx * 64 + pi - 1;
 
  163                 for (++idx; idx < ArSize; ++idx)
 
  168                                 return idx * 64 + pi - 1;
 
  182                 for (; pi >= 0; pi = 
next(pi))
 
  191                 for (
int ai=0; ai<ArSize; ++ai)
 
  193                         if (m_ar[ai]) 
return false;
 
  199         enum {ArSize=(SIZE+63)/64};
 
  200         uint64_t m_ar[ ArSize];
 
bool test(int pos) const 
Definition: bitset.hpp:67
bool set(int pos, bool value)
Definition: bitset.hpp:51
bitset(const bitset &o)
Definition: bitset.hpp:42
bitset()
Definition: bitset.hpp:34
Definition: bitset.hpp:19
static uint64_t mask(uint64_t hi)
Definition: bitset.hpp:21
void reset()
Definition: bitset.hpp:144
bool empty() const 
Definition: bitset.hpp:189
int next(int pos) const 
Definition: bitset.hpp:150
Definition: bitset.hpp:31
static unsigned int bitScanForward(const uint32_t &idx)
Definition: bitOperations.hpp:107
static uint64_t mask(uint64_t hi)
Definition: bitset.hpp:26
bool insert(int pos, bool value)
Definition: bitset.hpp:75
int first() const 
Definition: bitset.hpp:173
std::vector< int > elements() const 
Definition: bitset.hpp:178