Base class of libecc::bitset. More...
#include <libecc/bitset.h>
Public Types | |
typedef bitset_iterator< N, forwards_iterating > | const_iterator |
Non-mutable iterator. | |
typedef bitset_iterator< N, backwards_iterating > | const_reverse_iterator |
Reverse non-mutable iterator. | |
Public Member Functions | |
const_iterator | begin (void) const |
Return an iterator to the first bit. | |
const_iterator | end (void) const |
Return an iterator one past the last bit. | |
const_reverse_iterator | rbegin (void) const |
Return a reverse iterator to bit N-1. | |
const_reverse_iterator | rend (void) const |
Return a reverse iterator one before the first bit. | |
template<unsigned int m> | |
void | xor_with_zero_padded (bitset_base< m > const &bitset, int lsb, int msb, int shift) |
Shift bitset left or right and XOR with this bitset. | |
bool | test (size_t n) const |
Test bit at position pos. | |
bool | odd (void) const |
Returns true when the bitset contains an odd number of bits. | |
void | set (size_t n) |
Set bit at position pos. | |
void | clear (size_t n) |
Clear bit at position pos. | |
void | flip (size_t n) |
Toggle bit at position pos. | |
bool | test (bitset_index const &index) const |
Test a bit at position index. | |
void | set (bitset_index const &index) |
Set bit at position index. | |
void | clear (bitset_index const &index) |
Clear bit at position index. | |
void | flip (bitset_index const &index) |
Toggle bit at position index. | |
template<unsigned int pos> | |
bool | test (void) const |
Test a bit at a fixed position. | |
template<unsigned int pos> | |
void | set (void) |
Set a bit at a fixed position. | |
template<unsigned int pos> | |
void | clear (void) |
Clear a bit at a fixed position. | |
template<unsigned int pos> | |
void | flip (void) |
Toggle a bit at a fixed position. | |
void | reset (void) |
Reset all bits to 0. | |
void | setall (void) |
Set all bits to 1. | |
bool | any (void) const |
Return true if any bit is set. | |
Static Public Attributes | |
static unsigned int const | number_of_bits |
The number of bits in the bitset. | |
static unsigned int const | digits |
The minimum number of digits needed to store N bits. | |
static bitset_digit_t const | valid_bits |
A mask marking the valid bits in the most significant digit. | |
static bool const | has_excess_bits |
True when not all bits in the most significant digit are valid. | |
Protected Attributes | |
bitset_digit_t | vector [digits] |
The actual bits, stored as an array of digits number of "digits" of type libecc::bitset_digit_t. |
Base class of libecc::bitset.
This class is for internal use only. It contains the actual data, an array of bitset_digit_t , the meaning of which is determined by the derived classes; direct access of the data is therefore useless and prohibited (vector is protected).
typedef bitset_iterator<N, forwards_iterating> libecc::bitset_base< N >::const_iterator |
Non-mutable iterator.
typedef bitset_iterator<N, backwards_iterating> libecc::bitset_base< N >::const_reverse_iterator |
Reverse non-mutable iterator.
bool libecc::bitset_base< N >::any | ( | void | ) | const |
Return true if any bit is set.
References libecc::bitset_base< N >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::polynomial().
const_iterator libecc::bitset_base< N >::begin | ( | void | ) | const [inline] |
Return an iterator to the first bit.
Referenced by libecc::polynomial< m, k, k1, k2 >::operator/=().
void libecc::bitset_base< N >::clear | ( | size_t | n | ) | [inline] |
Clear bit at position pos.
References libecc::bitset_base< N >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::sqrt().
void libecc::bitset_base< N >::clear | ( | bitset_index const & | index | ) | [inline] |
Clear bit at position index.
References libecc::bitset_base< N >::clear(), libecc::bitset_index::get_index(), and libecc::bitset_base< N >::vector.
void libecc::bitset_base< N >::clear | ( | void | ) | [inline] |
Clear a bit at a fixed position.
References libecc::bitset_base< N >::vector.
Referenced by libecc::bitset_base< N >::clear().
const_iterator libecc::bitset_base< N >::end | ( | void | ) | const [inline] |
Return an iterator one past the last bit.
void libecc::bitset_base< N >::flip | ( | size_t | n | ) | [inline] |
Toggle bit at position pos.
References libecc::bitset_base< N >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::operator/=(), and libecc::polynomial< m, k, k1, k2 >::sqrt().
void libecc::bitset_base< N >::flip | ( | bitset_index const & | index | ) | [inline] |
Toggle bit at position index.
References libecc::bitset_base< N >::flip(), libecc::bitset_index::get_index(), and libecc::bitset_base< N >::vector.
void libecc::bitset_base< N >::flip | ( | void | ) | [inline] |
Toggle a bit at a fixed position.
References libecc::bitset_base< N >::vector.
Referenced by libecc::bitset_base< N >::flip().
bool libecc::bitset_base< N >::odd | ( | void | ) | const |
Returns true when the bitset contains an odd number of bits.
References libecc::bitset_base< N >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::polynomial().
const_reverse_iterator libecc::bitset_base< N >::rbegin | ( | void | ) | const [inline] |
Return a reverse iterator to bit N-1.
Referenced by libecc::gcd(), and libecc::polynomial< m, k, k1, k2 >::operator/=().
const_reverse_iterator libecc::bitset_base< N >::rend | ( | void | ) | const [inline] |
Return a reverse iterator one before the first bit.
void libecc::bitset_base< N >::reset | ( | void | ) |
Reset all bits to 0.
References libecc::bitset_base< N >::vector.
Referenced by libecc::bitset< N >::bitset(), libecc::polynomial< m, k, k1, k2 >::polynomial(), libecc::sha1::process_msg(), and libecc::polynomial< m, k, k1, k2 >::sqrt().
void libecc::bitset_base< N >::set | ( | bitset_index const & | index | ) | [inline] |
Set bit at position index.
References libecc::bitset_index::get_index(), and libecc::bitset_base< N >::vector.
void libecc::bitset_base< N >::set | ( | void | ) | [inline] |
Set a bit at a fixed position.
References libecc::bitset_base< N >::vector.
void libecc::bitset_base< N >::set | ( | size_t | n | ) | [inline] |
Set bit at position pos.
References libecc::bitset_base< N >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::polynomial(), libecc::sha1::process_msg(), and libecc::polynomial< m, k, k1, k2 >::sqrt().
void libecc::bitset_base< N >::setall | ( | void | ) |
Set all bits to 1.
References libecc::bitset_base< N >::vector.
bool libecc::bitset_base< N >::test | ( | bitset_index const & | index | ) | const [inline] |
Test a bit at position index.
References libecc::bitset_index::get_index(), libecc::bitset_base< N >::test(), and libecc::bitset_base< N >::vector.
bool libecc::bitset_base< N >::test | ( | size_t | n | ) | const [inline] |
Test bit at position pos.
References libecc::bitset_base< N >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::operator/=(), libecc::polynomial< m, k, k1, k2 >::polynomial(), and libecc::polynomial< m, k, k1, k2 >::sqrt().
bool libecc::bitset_base< N >::test | ( | void | ) | const [inline] |
Test a bit at a fixed position.
References libecc::bitset_base< N >::vector.
Referenced by libecc::bitset_base< N >::test().
void libecc::bitset_base< N >::xor_with_zero_padded | ( | bitset_base< m > const & | bitset, | |
int | lsb, | |||
int | msb, | |||
int | shift | |||
) |
Shift bitset left or right and XOR with this bitset.
bitset | The input bitset. | |
lsb | The Least Significant set bit of bitset. | |
msb | The Most Significant set bit in bitset. | |
shift | The distance to shift to the left, may be negative in which case bitset is shifted right. |
Bit lsb up till and including bit msb of bitset are shifted left over a distance shift (or shifted right if shift is negative) and then bitwise exclusive-OR-ed with this bitset. No range checking for this bitset is being done; it is the responsibility of the caller to make sure that it will fit. Moreover, it is assumed that all bits in the same digit but left of msb and and right of lsb are zero and that that there is at least one fully zeroed digit left and right of the bitset.
References libecc::bitset_base< N >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::operator/=().
unsigned int const libecc::bitset_base< N >::digits [static] |
The minimum number of digits needed to store N bits.
bool const libecc::bitset_base< N >::has_excess_bits [static] |
True when not all bits in the most significant digit are valid.
unsigned int const libecc::bitset_base< N >::number_of_bits [static] |
The number of bits in the bitset.
This constant is simply equal to N.
bitset_digit_t const libecc::bitset_base< N >::valid_bits [static] |
A mask marking the valid bits in the most significant digit.
bitset_digit_t libecc::bitset_base< N >::vector[digits] [protected] |
The actual bits, stored as an array of digits number of "digits" of type libecc::bitset_digit_t.
The first digit is the least significant digit: printing is done from high index to low index. The bits in the array can represent the actual bits or the inverted bits of the bitset, depending on the type of the derived class.
Referenced by libecc::bitset_base< N >::any(), libecc::bitset< N >::bitset(), libecc::bitset< 512 >::bitset(), libecc::bitset_base< N >::clear(), libecc::bitset_base< N >::flip(), libecc::bitset_base< N >::odd(), libecc::operator==(), libecc::bitset_base< N >::reset(), libecc::bitset_base< N >::set(), libecc::bitset_base< N >::setall(), libecc::bitset< N >::shift_op(), libecc::bitset_base< N >::test(), and libecc::bitset_base< N >::xor_with_zero_padded().