Fixed FeldmanHashSet
[libcds.git] / cds / algo / split_bitstring.h
index 605d00ec9d8cb6dc941b101cf8ce4a02f988d782..82cf1242635f6faad52a9aa66194290d3cd0506e 100644 (file)
@@ -44,7 +44,7 @@ namespace cds { namespace algo {
         /// Initializises the splitter with reference to \p h and start bit offset \p nBitOffset
         split_bitstring( bitstring const& h, size_t nBitOffset )
             : m_ptr( reinterpret_cast<uint_type const*>( &h ) + nBitOffset / c_nBitPerInt )
-            , m_pos( nBitOffset % c_nBitPerInt )
+            , m_pos( nBitOffset )
             , m_first( reinterpret_cast<uint_type const*>(&h))
 #   ifdef _DEBUG
             , m_last( m_first + c_nHashSize )
@@ -90,6 +90,7 @@ namespace cds { namespace algo {
             else if ( nBits == nRest ) {
                 result = *m_ptr >> ( c_nBitPerInt - nRest );
                 ++m_ptr;
+                assert( m_pos % c_nBitPerInt == 0 );
             }
             else {
                 uint_type const lsb = *m_ptr >> ( c_nBitPerInt - nRest );
@@ -139,6 +140,12 @@ namespace cds { namespace algo {
             return reinterpret_cast<bitstring const *>( m_first );
         }
 
+        /// Returns current bit offset from beginning of bit-string
+        size_t bit_offset() const
+        {
+            return m_pos;
+        }
+
     private:
         //@cond
         uint_type const* m_ptr;  ///< current position in the hash