Modernized GAlib  3.0.0 current
Public Member Functions | Protected Attributes | List of all members
GABinaryString Class Reference

This header defines the interface for the binary string. More...

#include <GABinStr.hpp>

Inheritance diagram for GABinaryString:
[legend]
Collaboration diagram for GABinaryString:
[legend]

Public Member Functions

 GABinaryString (unsigned int s)
 
void copy (const GABinaryString &orig)
 Copy the contents of the bitstream. More...
 
int resize (unsigned int x)
 Resize the bitstream to the specified number of bits. More...
 
int size () const
 
short bit (unsigned int a) const
 
short bit (unsigned int a, short val)
 
bool equal (const GABinaryString &rhs, unsigned int lhsIdx, unsigned int rhsIdx, unsigned int l) const
 Are two (subset) bitstreams equal? More...
 
void copy (const GABinaryString &orig, unsigned int destIdx, unsigned int origIdx, unsigned int l)
 
void move (unsigned int destIdx, unsigned int sourceIdx, unsigned int l)
 Copy (sub) bitstream. More...
 
void set (unsigned int a, unsigned int l)
 
void unset (unsigned int a, unsigned int l)
 
void randomize (unsigned int a, unsigned int l)
 
void randomize ()
 

Protected Attributes

std::vector< GABit > data
 the data themselves
 

Detailed Description

This header defines the interface for the binary string.

This is a crude version of a real bitstring object. We don't do real bitstring in the interest of speed and ease of coding this mess up.

Todo:
we can get major improvements to speed by inlining functions and getting rid of the error checking... for example, inlining genome and removing the conditional makes it go from 7.5 seconds to 3.2 seconds (bm bl cs 1024 c 0.9)

Member Function Documentation

◆ copy() [1/2]

void GABinaryString::copy ( const GABinaryString orig)
inline

Copy the contents of the bitstream.

Parameters
orig

◆ copy() [2/2]

void GABinaryString::copy ( const GABinaryString orig,
unsigned int  destIdx,
unsigned int  origIdx,
unsigned int  l 
)
inline
Parameters
origCopy from here
destIdxStart index of destination to copy
origIdxStart index of source from where we copy
llength Length of copied bitstream

◆ equal()

bool GABinaryString::equal ( const GABinaryString rhs,
unsigned int  lhsIdx,
unsigned int  rhsIdx,
unsigned int  l 
) const
inline

Are two (subset) bitstreams equal?

Parameters
rhsRight hand side bitstream to compare
lhsIdxStart index of left hand side bitstream
rhsIdxStart index of right hand side bitstream
llength of bitstream to compare
Returns
True, if equal

◆ move()

void GABinaryString::move ( unsigned int  destIdx,
unsigned int  sourceIdx,
unsigned int  l 
)
inline

Copy (sub) bitstream.

Todo:
Check, if it is a bug, that it's a copy not a move
Parameters
destIdxStart index of destination
sourceIdxStart index of source
llength

◆ resize()

int GABinaryString::resize ( unsigned int  x)
inline

Resize the bitstream to the specified number of bits.

We return the number of bits actually allocated. The new allocated space not used is set to zeros.

Parameters
xdesired size [bits]
Returns
the new size

The documentation for this class was generated from the following file: