21 #ifndef G_BIT_ITERATOR__H
22 #define G_BIT_ITERATOR__H
45 typedef T byte_iterator_type ;
69 void normalise()
const ;
72 mutable unsigned char m_mask ;
87 unsigned char c =
static_cast<unsigned char>( *m_p ) ;
88 return ( c & m_mask ) ? 1U : 0U ;
102 template <
typename T>
110 template <
typename T>
119 template <
typename T>
132 return m_p == other.m_p && m_mask == other.m_mask ;
135 template <
typename T>
138 return ! ( *
this == other ) ;
141 template <
typename T>
144 size_t n = std::distance(other.m_p,m_p) * 8 ;
145 unsigned int mask = m_mask ;
146 unsigned int other_mask = other.m_mask ;
147 if( mask == 0 ) mask = 0x80 , n += 8 ;
148 if( other_mask == 0 ) other_mask = 0x80 , n -= 8 ;
149 for( ; mask != 0x80 ; mask <<= 1 ) n++ ;
150 for( ; other_mask != 0x80 ; other_mask <<= 1 ) n-- ;
bit_iterator & operator++()
Advance operator. Moves from msb to lsb within each byte.
bool operator==(const bit_iterator &other) const
Comparison operator.
unsigned int operator*() const
Dereference operator, returning one or zero.
size_t operator-(const bit_iterator &other) const
Subtraction operator.
A bit-by-bit input iterator that extracts bits in msb-to-lsb order from a sequence of bytes...
bool operator!=(const bit_iterator &other) const
Comparison operator.
bit_iterator(T bytewise_input_iterator)
Constructor. Points to the msb of the given byte.