Empirical
Public Member Functions | Static Public Member Functions | List of all members
emp::BitMatrix< COLS, ROWS > Class Template Reference

A simple class to manage a COLS x ROWS matrix of bits. More...

#include <BitMatrix.h>

Public Member Functions

template<size_t START_POS, size_t STEP_POS, size_t END_POS>
constexpr BitSet< COLS *ROWS > Mask () const
 
 BitMatrix ()
 
 BitMatrix (const BitSet< COLS *ROWS > &in_bits)
 
 BitMatrix (const BitMatrix &in_matrix)
 
 ~BitMatrix ()
 
constexpr size_t NumRows () const
 How many rows are in this matrix? More...
 
constexpr size_t NumCols () const
 How many columns are in this matrix? More...
 
constexpr size_t GetSize () const
 How many total cells are in this matrix? More...
 
bool Any () const
 
bool None () const
 
bool All () const
 
bool Get (size_t col, size_t row) const
 
bool Get (size_t id) const
 
void Set (size_t col, size_t row, bool val=true)
 
void Set (size_t id)
 
void Unset (size_t col, size_t row)
 
void Unset (size_t id)
 
void Flip (size_t col, size_t row)
 
void Flip (size_t id)
 
void SetAll ()
 
void SetCol (size_t col)
 
void SetRow (size_t row)
 
void Clear ()
 
void ClearCol (size_t col)
 
void ClearRow (size_t row)
 
size_t CountOnes () const
 
int FindBit () const
 
BitMatrix LeftShift () const
 
BitMatrix RightShift () const
 
BitMatrix UpShift () const
 
BitMatrix DownShift () const
 
BitMatrix ULShift () const
 
BitMatrix DLShift () const
 
BitMatrix URShift () const
 
BitMatrix DRShift () const
 
BitMatrix GetReach () const
 
BitMatrix GetRegion (size_t start_pos) const
 
BitMatrix GetRegion (size_t col, size_t row) const
 
bool IsConnected () const
 
bool Has2x2 () const
 
void Print (std::ostream &os=std::cout) const
 
BitMatrixoperator= (const BitMatrix &in)
 
BitMatrixoperator&= (const BitMatrix &in)
 
BitMatrixoperator|= (const BitMatrix &in)
 
BitMatrixoperator^= (const BitMatrix &in)
 
bool operator== (const BitMatrix &in) const
 
bool operator!= (const BitMatrix &in) const
 
BitMatrix operator~ () const
 
BitMatrix operator& (const BitMatrix &in) const
 
BitMatrix operator| (const BitMatrix &in) const
 
BitMatrix operator^ (const BitMatrix &in) const
 
const BitSet< COLS *ROWS > & to_bitset ()
 

Static Public Member Functions

template<size_t COL_ID>
static const BitSet< COLS *ROWS > & MaskCol ()
 Keep only a single column of values, reducing all others to zeros. More...
 
template<size_t ROW_ID>
static const BitSet< COLS *ROWS > & MaskRow ()
 Keep only a single row of values, reducing all others to zeros. More...
 
static size_t ToCol (size_t id)
 Identify which column a specific ID is part of. More...
 
static size_t ToRow (size_t id)
 Identify which row a specific ID is part of. More...
 
static size_t ToID (size_t col, size_t row)
 Identify the ID associated with a specified row and column. More...
 

Detailed Description

template<size_t COLS, size_t ROWS>
class emp::BitMatrix< COLS, ROWS >

A simple class to manage a COLS x ROWS matrix of bits.

Bits are translated to a bitset with 0 in the upper left and moving through bits from left to right and top to bottom. For example, the indecies in a 3x3 bit matrix would be organized as such:

0 1 2 3 4 5 6 7 8

Constructor & Destructor Documentation

template<size_t COLS, size_t ROWS>
emp::BitMatrix< COLS, ROWS >::BitMatrix ( )
inline
template<size_t COLS, size_t ROWS>
emp::BitMatrix< COLS, ROWS >::BitMatrix ( const BitSet< COLS *ROWS > &  in_bits)
inline
template<size_t COLS, size_t ROWS>
emp::BitMatrix< COLS, ROWS >::BitMatrix ( const BitMatrix< COLS, ROWS > &  in_matrix)
inline
template<size_t COLS, size_t ROWS>
emp::BitMatrix< COLS, ROWS >::~BitMatrix ( )
inline

Member Function Documentation

template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::All ( ) const
inline
template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::Any ( ) const
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Clear ( )
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::ClearCol ( size_t  col)
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::ClearRow ( size_t  row)
inline
template<size_t COLS, size_t ROWS>
size_t emp::BitMatrix< COLS, ROWS >::CountOnes ( ) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::DLShift ( ) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::DownShift ( ) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::DRShift ( ) const
inline
template<size_t COLS, size_t ROWS>
int emp::BitMatrix< COLS, ROWS >::FindBit ( ) const
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Flip ( size_t  col,
size_t  row 
)
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Flip ( size_t  id)
inline
template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::Get ( size_t  col,
size_t  row 
) const
inline
template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::Get ( size_t  id) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::GetReach ( ) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::GetRegion ( size_t  start_pos) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::GetRegion ( size_t  col,
size_t  row 
) const
inline
template<size_t COLS, size_t ROWS>
constexpr size_t emp::BitMatrix< COLS, ROWS >::GetSize ( ) const
inline

How many total cells are in this matrix?

template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::Has2x2 ( ) const
inline
template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::IsConnected ( ) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::LeftShift ( ) const
inline
template<size_t COLS, size_t ROWS>
template<size_t START_POS, size_t STEP_POS, size_t END_POS>
constexpr BitSet<COLS*ROWS> emp::BitMatrix< COLS, ROWS >::Mask ( ) const
inline
template<size_t COLS, size_t ROWS>
template<size_t COL_ID>
static const BitSet<COLS*ROWS>& emp::BitMatrix< COLS, ROWS >::MaskCol ( )
inlinestatic

Keep only a single column of values, reducing all others to zeros.

template<size_t COLS, size_t ROWS>
template<size_t ROW_ID>
static const BitSet<COLS*ROWS>& emp::BitMatrix< COLS, ROWS >::MaskRow ( )
inlinestatic

Keep only a single row of values, reducing all others to zeros.

template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::None ( ) const
inline
template<size_t COLS, size_t ROWS>
constexpr size_t emp::BitMatrix< COLS, ROWS >::NumCols ( ) const
inline

How many columns are in this matrix?

template<size_t COLS, size_t ROWS>
constexpr size_t emp::BitMatrix< COLS, ROWS >::NumRows ( ) const
inline

How many rows are in this matrix?

template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::operator!= ( const BitMatrix< COLS, ROWS > &  in) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::operator& ( const BitMatrix< COLS, ROWS > &  in) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix& emp::BitMatrix< COLS, ROWS >::operator&= ( const BitMatrix< COLS, ROWS > &  in)
inline
template<size_t COLS, size_t ROWS>
BitMatrix& emp::BitMatrix< COLS, ROWS >::operator= ( const BitMatrix< COLS, ROWS > &  in)
inline
template<size_t COLS, size_t ROWS>
bool emp::BitMatrix< COLS, ROWS >::operator== ( const BitMatrix< COLS, ROWS > &  in) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::operator^ ( const BitMatrix< COLS, ROWS > &  in) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix& emp::BitMatrix< COLS, ROWS >::operator^= ( const BitMatrix< COLS, ROWS > &  in)
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::operator| ( const BitMatrix< COLS, ROWS > &  in) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix& emp::BitMatrix< COLS, ROWS >::operator|= ( const BitMatrix< COLS, ROWS > &  in)
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::operator~ ( ) const
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Print ( std::ostream &  os = std::cout) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::RightShift ( ) const
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Set ( size_t  col,
size_t  row,
bool  val = true 
)
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Set ( size_t  id)
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::SetAll ( )
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::SetCol ( size_t  col)
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::SetRow ( size_t  row)
inline
template<size_t COLS, size_t ROWS>
const BitSet<COLS*ROWS>& emp::BitMatrix< COLS, ROWS >::to_bitset ( )
inline
template<size_t COLS, size_t ROWS>
static size_t emp::BitMatrix< COLS, ROWS >::ToCol ( size_t  id)
inlinestatic

Identify which column a specific ID is part of.

template<size_t COLS, size_t ROWS>
static size_t emp::BitMatrix< COLS, ROWS >::ToID ( size_t  col,
size_t  row 
)
inlinestatic

Identify the ID associated with a specified row and column.

template<size_t COLS, size_t ROWS>
static size_t emp::BitMatrix< COLS, ROWS >::ToRow ( size_t  id)
inlinestatic

Identify which row a specific ID is part of.

template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::ULShift ( ) const
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Unset ( size_t  col,
size_t  row 
)
inline
template<size_t COLS, size_t ROWS>
void emp::BitMatrix< COLS, ROWS >::Unset ( size_t  id)
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::UpShift ( ) const
inline
template<size_t COLS, size_t ROWS>
BitMatrix emp::BitMatrix< COLS, ROWS >::URShift ( ) const
inline

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