StochHMM
v0.34
Flexible Hidden Markov Model C++ Library and Application
|
#include <dynamic_bitset.h>
Classes | |
class | bit_ref |
Public Member Functions | |
dynamic_bitset () | |
dynamic_bitset (size_t) | |
dynamic_bitset (const dynamic_bitset &) | |
dynamic_bitset (const std::string &) | |
dynamic_bitset (const std::vector< bool > &) | |
void | resize (size_t) |
void | reserve (size_t) |
bool | empty () |
void | clear () |
bool | operator[] (size_t pos) const |
bit_ref | operator[] (size_t pos) |
dynamic_bitset | operator& (const dynamic_bitset &rhs) |
dynamic_bitset | operator| (const dynamic_bitset &rhs) |
dynamic_bitset | operator^ (const dynamic_bitset &rhs) |
dynamic_bitset | operator~ () const |
dynamic_bitset & | operator= (const dynamic_bitset &rhs) |
dynamic_bitset & | operator&= (const dynamic_bitset &rhs) |
Bitwise AND all the bits with all the bits in the rhs. | |
dynamic_bitset & | operator|= (const dynamic_bitset &rhs) |
Bitwise OR all the bits with all the bits in the rhs. | |
dynamic_bitset & | operator^= (const dynamic_bitset &rhs) |
Bitwise XOR all the bits with all the bits in the rhs. | |
dynamic_bitset & | operator-= (const dynamic_bitset &rhs) |
dynamic_bitset & | operator<<= (size_t n) |
dynamic_bitset & | operator>>= (size_t n) |
dynamic_bitset | operator<< (size_t n) |
dynamic_bitset | operator>> (size_t n) |
void | insert (size_t pos, size_t n) |
void | erase (size_t pos) |
dynamic_bitset | get_intersection (const dynamic_bitset &rhs) |
dynamic_bitset | get_union (const dynamic_bitset &rhs) |
dynamic_bitset | get_unique (const dynamic_bitset &rhs) |
Return only the bits that are uniqe to bitset. | |
bool | operator== (const dynamic_bitset &rhs) const |
bool | operator!= (const dynamic_bitset &rhs) const |
size_t | size () |
bool | at (size_t pos) const |
bool | test (size_t pos) |
void | set (size_t pos) |
void | set (size_t pos, bool value) |
void | unset (size_t pos) |
void | flip () |
void | flip (size_t pos) |
void | reset () |
Resets all the bits to zero. | |
void | reset (size_t pos) |
Clears the bit as position. | |
bool | any () |
bool | none () |
void | push_back (bool) |
size_t | count () const |
size_t | count_before (size_t) const |
size_t | find_first () const |
size_t | find_first (size_t pos) const |
size_t | find_last () const |
size_t | find_last (size_t pos) const |
bool | parity () |
std::string | stringify () const |
std::string | stringify_all () const |
Returns string representation of bitset includes buffered bits. | |
bool | intersects (const dynamic_bitset &) const |
Private Attributes | |
size_t | buffer |
size_t | current_size |
size_t | num_ints |
std::vector< uint32_t > | array |
Friends | |
std::ostream & | operator<< (std::ostream &, const dynamic_bitset &) |
A dynamic bitset class Allows the bitset to be set dynamically and manipulated in size dynamic_bitset uses 32 bit unsigned integers as the underlying datatype. Need to implement shifting to right and left Note: This dynamic_bitset is read from left to right This class can be greatly improved by using SSE optimization For portability and time issues: SSE optimization haven't been implemented yet.
Definition at line 30 of file dynamic_bitset.h.
|
inline |
Definition at line 32 of file dynamic_bitset.h.
StochHMM::dynamic_bitset::dynamic_bitset | ( | size_t | sz | ) |
StochHMM::dynamic_bitset::dynamic_bitset | ( | const dynamic_bitset & | rhs | ) |
Definition at line 21 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
StochHMM::dynamic_bitset::dynamic_bitset | ( | const std::string & | str | ) |
Definition at line 29 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
StochHMM::dynamic_bitset::dynamic_bitset | ( | const std::vector< bool > & | vec | ) |
Definition at line 53 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
bool StochHMM::dynamic_bitset::any | ( | ) |
bool StochHMM::dynamic_bitset::at | ( | size_t | pos | ) | const |
Returns state of bit at position *Performs range check first
Definition at line 589 of file dynamic_bitset.cpp.
References array, and current_size.
Referenced by stringify(), and test().
void StochHMM::dynamic_bitset::clear | ( | ) |
Clears the complete bitset *Size is reduced to zero
Definition at line 148 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
size_t StochHMM::dynamic_bitset::count | ( | ) | const |
Returns the number of 1's in the bitset bits.sephan-brumme countBits population
Definition at line 997 of file dynamic_bitset.cpp.
References array, and num_ints.
Referenced by StochHMM::sparseArray< double >::elements().
size_t StochHMM::dynamic_bitset::count_before | ( | size_t | pos | ) | const |
Returns the number of 1's in the bitset to the right of the current position bits.sephan-brumme countBits population
Definition at line 1019 of file dynamic_bitset.cpp.
References array.
|
inline |
void StochHMM::dynamic_bitset::erase | ( | size_t | pos | ) |
Erase the bit at the position from the set. *Causes the bits to shift right by one
Definition at line 478 of file dynamic_bitset.cpp.
References array, buffer, current_size, StochHMM::maskLeft(), StochHMM::maskRight(), num_ints, StochHMM::rso(), and SIZE_MAX.
size_t StochHMM::dynamic_bitset::find_first | ( | ) | const |
Find first set bit within bitset and return the position *Searches from beginning to end. (Left to Right)
Definition at line 758 of file dynamic_bitset.cpp.
References array, num_ints, and SIZE_MAX.
size_t StochHMM::dynamic_bitset::find_first | ( | size_t | pos | ) | const |
Find the first bit within the bitset starting at position pos *Searches from beginning to end. (Left to Right)
pos | Position to start the search |
Definition at line 792 of file dynamic_bitset.cpp.
References array, current_size, num_ints, and SIZE_MAX.
size_t StochHMM::dynamic_bitset::find_last | ( | ) | const |
Searches in reverse to find first set bit within bitset and return the position *Searches from end to beginning. (Right to Left)
Definition at line 856 of file dynamic_bitset.cpp.
References array, num_ints, and SIZE_MAX.
size_t StochHMM::dynamic_bitset::find_last | ( | size_t | pos | ) | const |
Definition at line 893 of file dynamic_bitset.cpp.
References array, current_size, and SIZE_MAX.
void StochHMM::dynamic_bitset::flip | ( | ) |
Flips the whole bitset *Complete bitset gets assigned the complement bitset
Definition at line 665 of file dynamic_bitset.cpp.
void StochHMM::dynamic_bitset::flip | ( | size_t | pos | ) |
dynamic_bitset StochHMM::dynamic_bitset::get_intersection | ( | const dynamic_bitset & | rhs | ) |
Return the intersection bitset with rhs bitset Same as bitwise AND
dynamic_bitset& |
Definition at line 553 of file dynamic_bitset.cpp.
dynamic_bitset StochHMM::dynamic_bitset::get_union | ( | const dynamic_bitset & | rhs | ) |
Returns the union bitset Same as bitwise OR
Definition at line 559 of file dynamic_bitset.cpp.
dynamic_bitset StochHMM::dynamic_bitset::get_unique | ( | const dynamic_bitset & | rhs | ) |
Return only the bits that are uniqe to bitset.
Definition at line 564 of file dynamic_bitset.cpp.
void StochHMM::dynamic_bitset::insert | ( | size_t | pos, |
size_t | n | ||
) |
Insert n bits (set to zero) at the position. Bitsets at this position and *greater will be shifted to the left. This will increase the size of the bitset
Definition at line 384 of file dynamic_bitset.cpp.
References array, buffer, current_size, StochHMM::lso(), StochHMM::maskLeft(), StochHMM::maskRight(), and num_ints.
bool StochHMM::dynamic_bitset::intersects | ( | const dynamic_bitset & | ) | const |
bool StochHMM::dynamic_bitset::none | ( | ) |
bool StochHMM::dynamic_bitset::operator!= | ( | const dynamic_bitset & | rhs | ) | const |
Checks to see if bitset is not equal to *this
Bitset | to compare with *this |
Definition at line 293 of file dynamic_bitset.cpp.
dynamic_bitset StochHMM::dynamic_bitset::operator& | ( | const dynamic_bitset & | rhs | ) |
Bitwise - AND operator
Definition at line 159 of file dynamic_bitset.cpp.
dynamic_bitset & StochHMM::dynamic_bitset::operator&= | ( | const dynamic_bitset & | rhs | ) |
Bitwise AND all the bits with all the bits in the rhs.
Definition at line 208 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
dynamic_bitset& StochHMM::dynamic_bitset::operator-= | ( | const dynamic_bitset & | rhs | ) |
dynamic_bitset StochHMM::dynamic_bitset::operator<< | ( | size_t | n | ) |
Definition at line 333 of file dynamic_bitset.cpp.
dynamic_bitset & StochHMM::dynamic_bitset::operator<<= | ( | size_t | n | ) |
Shift the bitset to the left n positions *Size of the bitset will not change. If values are shifted off bitset then *they will be lost.
n | Number of positions to shift the bits |
Definition at line 306 of file dynamic_bitset.cpp.
References array, buffer, StochHMM::lso(), StochHMM::lsoso(), and num_ints.
dynamic_bitset & StochHMM::dynamic_bitset::operator= | ( | const dynamic_bitset & | rhs | ) |
Overloaded assignment operator makes *this a copy of rhs
rhs | dynamic_bitset to copy |
Definition at line 199 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
bool StochHMM::dynamic_bitset::operator== | ( | const dynamic_bitset & | rhs | ) | const |
Checks to see if bitset is equal to *this
Bitset | to compare with *this |
Definition at line 280 of file dynamic_bitset.cpp.
dynamic_bitset StochHMM::dynamic_bitset::operator>> | ( | size_t | n | ) |
Definition at line 374 of file dynamic_bitset.cpp.
dynamic_bitset & StochHMM::dynamic_bitset::operator>>= | ( | size_t | n | ) |
Shift the bitset to the right n positions *Size of the bitset will not change. If values are shifted off bitset then *they will be lost.
n | Number of positions to shift the bits |
Definition at line 344 of file dynamic_bitset.cpp.
References array, num_ints, StochHMM::rso(), StochHMM::rsoso(), and SIZE_MAX.
bool StochHMM::dynamic_bitset::operator[] | ( | size_t | pos | ) | const |
Get state of bit at position *No initial range check
Definition at line 575 of file dynamic_bitset.cpp.
References array.
dynamic_bitset::bit_ref StochHMM::dynamic_bitset::operator[] | ( | size_t | pos | ) |
Definition at line 581 of file dynamic_bitset.cpp.
References array.
dynamic_bitset StochHMM::dynamic_bitset::operator^ | ( | const dynamic_bitset & | rhs | ) |
Bitwise - XOR operator
Definition at line 175 of file dynamic_bitset.cpp.
dynamic_bitset & StochHMM::dynamic_bitset::operator^= | ( | const dynamic_bitset & | rhs | ) |
Bitwise XOR all the bits with all the bits in the rhs.
Definition at line 248 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
dynamic_bitset StochHMM::dynamic_bitset::operator| | ( | const dynamic_bitset & | rhs | ) |
Bitwise - OR operator
Definition at line 167 of file dynamic_bitset.cpp.
dynamic_bitset & StochHMM::dynamic_bitset::operator|= | ( | const dynamic_bitset & | rhs | ) |
Bitwise OR all the bits with all the bits in the rhs.
Definition at line 227 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
dynamic_bitset StochHMM::dynamic_bitset::operator~ | ( | ) | const |
Bitwise ~ Complement
Definition at line 183 of file dynamic_bitset.cpp.
References array, buffer, and num_ints.
bool StochHMM::dynamic_bitset::parity | ( | ) |
Returns whether there are an odd number of bits set
Definition at line 981 of file dynamic_bitset.cpp.
void StochHMM::dynamic_bitset::push_back | ( | bool | val | ) |
Pushes a bit onto the bitset *Increases the bitset size by 1
bool | Value to set in bitset |
Definition at line 721 of file dynamic_bitset.cpp.
References array, buffer, current_size, num_ints, reserve(), and unset().
void StochHMM::dynamic_bitset::reserve | ( | size_t | sz | ) |
Reserves the set amount of memory *Doesn't change any of the bitset size. Only reserve a set amount of memory.
Definition at line 134 of file dynamic_bitset.cpp.
References array, buffer, and current_size.
Referenced by push_back().
void StochHMM::dynamic_bitset::reset | ( | ) |
void StochHMM::dynamic_bitset::reset | ( | size_t | pos | ) |
void StochHMM::dynamic_bitset::resize | ( | size_t | sz | ) |
Resize the bitset. If size is smaller than bitset, those values will get deleted If size is larger than bitset, it will get extended.
Definition at line 109 of file dynamic_bitset.cpp.
References array, buffer, current_size, and num_ints.
void StochHMM::dynamic_bitset::set | ( | size_t | pos | ) |
Sets the bit at position with value *Checks size before assignment
position | within bitset |
Definition at line 617 of file dynamic_bitset.cpp.
References array, and current_size.
void StochHMM::dynamic_bitset::set | ( | size_t | pos, |
bool | val | ||
) |
Sets the bit at position with value *Checks size before assignment
position | within bitset |
val | Value to set bit |
Definition at line 634 of file dynamic_bitset.cpp.
References current_size, and unset().
|
inline |
Definition at line 100 of file dynamic_bitset.h.
References current_size.
Referenced by StochHMM::sparseArray< double >::size().
std::string StochHMM::dynamic_bitset::stringify | ( | ) | const |
Returns string representation of bitset
Definition at line 1054 of file dynamic_bitset.cpp.
References at(), current_size, SIZE_MAX, and test().
Referenced by StochHMM::operator<<().
std::string StochHMM::dynamic_bitset::stringify_all | ( | ) | const |
Returns string representation of bitset includes buffered bits.
Definition at line 1077 of file dynamic_bitset.cpp.
References array, StochHMM::intToBinString(), num_ints, and SIZE_MAX.
bool StochHMM::dynamic_bitset::test | ( | size_t | pos | ) |
Returns whether bit is set at the position *Performs range check first
pos | Position within bitset |
Definition at line 605 of file dynamic_bitset.cpp.
References at(), and current_size.
Referenced by flip(), and stringify().
void StochHMM::dynamic_bitset::unset | ( | size_t | pos | ) |
Unsets the bit at position *Checks size before assignment
Definition at line 650 of file dynamic_bitset.cpp.
References array, and current_size.
Referenced by flip(), push_back(), reset(), and set().
|
friend |
Overloaded ostream for using dynamic_bitsets in ostream *Usage: std::cout << bs << ....;
Definition at line 270 of file dynamic_bitset.cpp.
|
private |
Definition at line 141 of file dynamic_bitset.h.
Referenced by any(), at(), clear(), count(), count_before(), dynamic_bitset(), erase(), find_first(), find_last(), insert(), none(), operator!=(), operator&=(), operator<<=(), operator=(), operator==(), operator>>=(), operator[](), operator^=(), operator|=(), operator~(), parity(), push_back(), reserve(), reset(), resize(), set(), stringify_all(), and unset().
|
private |
Definition at line 137 of file dynamic_bitset.h.
Referenced by clear(), dynamic_bitset(), erase(), insert(), operator&=(), operator<<=(), operator=(), operator^=(), operator|=(), operator~(), push_back(), reserve(), and resize().
|
private |
Definition at line 138 of file dynamic_bitset.h.
Referenced by at(), clear(), dynamic_bitset(), empty(), erase(), find_first(), find_last(), insert(), operator&=(), operator=(), operator^=(), operator|=(), push_back(), reserve(), resize(), set(), size(), stringify(), test(), and unset().
|
private |
Definition at line 139 of file dynamic_bitset.h.
Referenced by any(), clear(), count(), dynamic_bitset(), erase(), find_first(), find_last(), insert(), none(), operator!=(), operator&=(), operator<<=(), operator=(), operator==(), operator>>=(), operator^=(), operator|=(), operator~(), parity(), push_back(), reset(), resize(), and stringify_all().