#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 | |
bitset (void) | |
Construct an uninitialized bitset of n bits. | |
bitset (std::string const &) | |
Construct a bitset of n bits and initialize it with the string input, a hexadecimal value in ASCII representation. | |
bitset (bitset_digit_t low_bits) | |
Construct a bitset of which only the least significant bits are set. | |
bitset (bitset_digit_t const (&v)[bitset_base< n >::digits]) | |
Construct a bitset directly from an array of bitset_digit_t. | |
template<unsigned int m, bool inverted> | |
bitset (bitset_invertible< m, inverted > const &) | |
Copy constructor. | |
template<unsigned int m, bool i1, bool i2, typename OP> | |
bitset (Operator::bitsetExpression< m, i1, i2, OP > const &expr) | |
Construct a bitset from an expression. | |
template<typename Expression> | |
bitset & | operator= (Expression const &) |
Assignment operator. | |
template<typename Expression> | |
bitset & | operator &= (Expression const &) |
Assignment operator with bitwise AND. | |
template<typename Expression> | |
bitset & | operator|= (Expression const &) |
Assignment operator with bitwise OR. | |
template<typename Expression> | |
bitset & | operator^= (Expression const &) |
Assignment operator with bitwise XOR. | |
template<unsigned int shift, class DIRECTION, class OPERATION> | |
void | shift_op (bitset &result) const |
Perform a shift operation followed by a bit operation. | |
bitset & | operator<<= (unsigned int shift) |
Shift bitset shift bits to the left. Use the faster bitset::shift_op for constant distance shifts. | |
bitset & | operator>>= (unsigned int shift) |
Shift bitset shift bits to the right. Use the faster bitset::shift_op for constant distance shifts. | |
template<unsigned int shift, class DIRECTION> | |
void | rotate (bitset &result) const |
Rotate 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. | |
bitset & | 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. | |
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< m > const &bitset, int lsb, int msb, int shift) |
Shift bitset left or right and XOR with this bitset. |
n | The number of bits in the bitset. |
typedef bitset_iterator<n, forwards_iterating> libecc::bitset< n >::const_iterator |
Non-mutable iterator.
typedef bitset_iterator<n, backwards_iterating> libecc::bitset< n >::const_reverse_iterator |
Reverse non-mutable iterator.
libecc::bitset< n >::bitset | ( | void | ) | [inline] |
libecc::bitset< n >::bitset | ( | std::string const & | input | ) | [inline] |
Construct a bitset of n bits and initialize it with the string input, a hexadecimal value in ASCII representation.
Input is a string of alphanumeric characters ([0-9A-F]) not case sensitive. The input string is read right to left. Any non-space character that is not a hexadecimal digit will terminate reading.
Spaces will be ignored, allowing one to write for example "C20 93B0D12C F78A9001 F6E2841F 0A918FCD
" instead of the less readable "C2093B0D12CF78A9001F6E2841F0A918FCD
". It is common practise to let each "word" represent an internal digit (32 bits in this example).
If the value passed is larger than fits in the bitset then the most significant bits (the left most characters) are ignored as if the value did fit and then a bit-wise AND was performed with a bitset of n 1's.
input | A hexadecimal value in ASCII representation. |
References libecc::bitset< n >::reset(), and libecc::bitset_base< n >::vector.
libecc::bitset< n >::bitset | ( | bitset_digit_t | low_bits | ) | [inline, explicit] |
Construct a bitset of which only the least significant bits are set.
low_bits must never have more bits set than the size of the bitset n.
References libecc::bitset_base< n >::vector.
libecc::bitset< n >::bitset | ( | bitset_digit_t const (&) | v[bitset_base< n >::digits] | ) | [inline] |
Construct a bitset directly from an array of bitset_digit_t.
The excess bits of the most significant digit (if any) must be zero.
libecc::bitset< n >::bitset | ( | bitset_invertible< m, inverted > const & | bits | ) | [inline] |
Copy constructor.
The least significant bit (at position 0) of bits and the constructed bitset are lined up. If bits is wider than the constructed bitset then excess bits are lost; if narrower then missing bits are set to inverted. That is, set to zero when bits is not inverted and set to one when bits represents an inverted bitset.
For example, when x is "0000000010001111" (16 bits), y is "10000000" (8 bits), then
x ^= ~y;
results in x being "1111111111110000".
libecc::bitset< n >::bitset | ( | Operator::bitsetExpression< m, i1, i2, OP > const & | expr | ) | [inline] |
bitset< n > & libecc::bitset< n >::operator= | ( | Expression const & | expr | ) | [inline] |
Assignment operator.
The least significant bits (at position 0) of expr and this bitset are lined up. If expr is wider than this bitset then excess bits are lost; if narrower then missing bits are set to zero or one depending on whether the expression contains inversion bits.
For example, when x is "0000000010001111" (16 bits), y is "10000000" (8 bits) and z is "11110110" (8 bits), then
x ^= ~y;
results in x being "1111111111110000". And
x |= ~y ^ ~z;
results in x being "0000000001110110".
bitset< n > & libecc::bitset< n >::operator &= | ( | Expression const & | expr | ) | [inline] |
Assignment operator with bitwise AND.
bitset< n > & libecc::bitset< n >::operator|= | ( | Expression const & | expr | ) | [inline] |
Assignment operator with bitwise OR.
bitset< n > & libecc::bitset< n >::operator^= | ( | Expression const & | expr | ) | [inline] |
Assignment operator with bitwise XOR.
void libecc::bitset< n >::shift_op | ( | bitset< n > & | result | ) | const [inline] |
Perform a shift operation followed by a bit operation.
Shift this object shift bits in DIRECTION and then perform operation OPERATION on result with it.
shift | the number of bits to shift this object. | |
DIRECTION | can be libecc::left or libecc::right. | |
OPERATION | can be either libecc::assign or libecc::exor. | |
result | The bitset that is used to XOR with, or to assign to. |
References libecc::bitset_invertible< n, false >::digit(), and libecc::bitset_base< n >::vector.
Referenced by libecc::bitset< n >::rotate().
bitset< n > & libecc::bitset< n >::operator<<= | ( | unsigned int | shift | ) | [inline] |
Shift bitset shift bits to the left. Use the faster bitset::shift_op for constant distance shifts.
References libecc::bitset_base< n >::vector.
bitset< n > & libecc::bitset< n >::operator>>= | ( | unsigned int | shift | ) | [inline] |
Shift bitset shift bits to the right. Use the faster bitset::shift_op for constant distance shifts.
References libecc::bitset_base< n >::vector.
void libecc::bitset< n >::rotate | ( | bitset< n > & | result | ) | const [inline] |
Rotate bitset.
Rotate bitset shift bits in DIRECTION.
shift | The number of bits to rotate this bitset. | |
DIRECTION | The direction into which this bitset must be rotated, can be libecc::left or libecc::right. | |
result | The result of the rotation. |
References libecc::bitset< n >::shift_op().
bool libecc::bitset< 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< n >::odd | ( | void | ) | const [inline] |
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().
void libecc::bitset< 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< 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< 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().
bool libecc::bitset< n >::test | ( | bitset_index const & | index | ) | const [inline] |
Test a bit at position index.
References libecc::bitset_index::get_index(), libecc::bitset< n >::test(), and libecc::bitset_base< n >::vector.
void libecc::bitset< 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< n >::clear | ( | bitset_index const & | index | ) | [inline] |
Clear bit at position index.
References libecc::bitset< n >::clear(), libecc::bitset_index::get_index(), and libecc::bitset_base< n >::vector.
void libecc::bitset< n >::flip | ( | bitset_index const & | index | ) | [inline] |
Toggle bit at position index.
References libecc::bitset< n >::flip(), libecc::bitset_index::get_index(), and libecc::bitset_base< n >::vector.
bool libecc::bitset< n >::test | ( | void | ) | const [inline] |
Test a bit at a fixed position.
References libecc::bitset_base< n >::vector.
Referenced by libecc::bitset< n >::test().
void libecc::bitset< n >::clear | ( | void | ) | [inline] |
Clear a bit at a fixed position.
References libecc::bitset_base< n >::vector.
Referenced by libecc::bitset< n >::clear().
void libecc::bitset< n >::flip | ( | void | ) | [inline] |
Toggle a bit at a fixed position.
References libecc::bitset_base< n >::vector.
Referenced by libecc::bitset< n >::flip().
bitset< n > & libecc::bitset< n >::reset | ( | void | ) | [inline] |
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< n >::setall | ( | void | ) | [inline] |
bool libecc::bitset< n >::any | ( | void | ) | const [inline] |
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< n >::begin | ( | void | ) | const [inline] |
Return an iterator to the first bit.
Referenced by libecc::polynomial< m, k, k1, k2 >::operator/=().
const_iterator libecc::bitset< n >::end | ( | void | ) | const [inline] |
Return an iterator one past the last bit.
const_reverse_iterator libecc::bitset< 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< n >::rend | ( | void | ) | const [inline] |
Return a reverse iterator one before the first bit.
void libecc::bitset< n >::xor_with_zero_padded | ( | bitset< m > const & | bitset, | |
int | lsb, | |||
int | msb, | |||
int | shift | |||
) | [inline] |
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. |
References libecc::bitset_invertible< n, false >::digit(), libecc::bitset_base< n >::digits_ptr(), and libecc::bitset_base< n >::vector.
Referenced by libecc::polynomial< m, k, k1, k2 >::operator/=().