The Original CHomP Software
|
A binary n-dimensional hypercube for storing cubes as bits. More...
#include <bincube.h>
Classes | |
class | iterator |
The iterator of the set of cubes within a bitmap. More... | |
class | neighborhood_iterator |
The neighborhood of a cube. More... | |
Public Member Functions | |
bincube () | |
The default constructor. More... | |
bincube (char *buffer) | |
The constructor to use a given memory buffer. More... | |
bincube (const bincube< Dim, twoPower > &b) | |
The copying constructor. More... | |
bincube< Dim, twoPower > & | operator= (const bincube< Dim, twoPower > &b) |
The assignment operator. More... | |
~bincube () | |
The destructor. More... | |
int | findcube (int start=0) const |
Finds the first existing cube beginning at the given number. More... | |
iterator | begin () |
Returns the iterator that points at the first cube in the set. More... | |
iterator | end () |
Returns the iterator that points beyond the end of the set. More... | |
neighborhood_iterator | neighborhood_begin (int number) const |
Creates a neighborhood iterator for the specified cube and sets it at the first cube. More... | |
neighborhood_iterator | neighborhood_end (int number) const |
Creates a one-behind-the-end iterator for the given cube. More... | |
void | add (int number) |
Sets the bit corresponding to the given cube (by number). More... | |
template<class intType > | |
void | add (const intType *coord) |
Sets the bit corresponding to the given cube (by number). More... | |
bool | check (int number) const |
Checks if the given cube belongs to the set or not. More... | |
template<class intType > | |
bool | check (const intType *coord) const |
Checks if the given cube belongs to the set or not. More... | |
void | remove (int number) |
Clears the bit corresponding to the given cube (by number). More... | |
template<class intType > | |
void | remove (const intType *coord) |
Clears the bit corresponding to the given cube (by number). More... | |
const char * | getbuffer () const |
Gets the binary buffer for reading only. More... | |
operator const char * () const | |
Gets the binary buffer for reading only. More... | |
std::istream & | read (std::istream &in) |
Reads the binary buffer from an input stream. More... | |
int | count () const |
Get the number of cubes in the set. More... | |
operator int () const | |
bool | empty () const |
Verifies whether the set is empty or not. More... | |
void | clear () |
Makes the set empty. More... | |
Static Public Member Functions | |
static int | dimension () |
Retrieves the dimension of the cube. More... | |
static int | getbufsize () |
Gets the buffer size. More... | |
static bool | wrapped (int dir) |
Verifies whether the space is wrapped in the given direction. More... | |
static void | wrap (int dir) |
Turns on wrapping in the given direction. More... | |
static void | dontwrap (int dir) |
Turns off wrapping in the given direction. More... | |
template<class intType > | |
static intType | wrap (intType coord, int dir) |
Wraps the coordinate in the given direction if necessary. More... | |
template<class intType > | |
static int | coord2num (const intType *coord) |
Determines the number of the cube with given coordinates. More... | |
template<class intType > | |
static intType * | num2coord (int number, intType *coord) |
Determines the coordinates of the cube with given number. More... | |
template<class intType > | |
static const intType * | num2coord (int number) |
Determines the coordinates of the cube with given number. More... | |
Static Public Attributes | |
static const int | MaxDim = Dim |
The maximal possible dimension of a cube. More... | |
static const int | max_neighbors = Power<3,Dim>::value - 1 |
The maximal possible number of neighbors of a cube. More... | |
static const int | maxcount = 1 << (Dim * twoPower) |
The maximal number of cubes that can be stored in the set. More... | |
Protected Attributes | |
char * | buf |
The memory for storing the hypercubes. More... | |
bool | allocated |
Was the memory for the buffer allocated? More... | |
int | cardinality |
The number of cubes in the set (or -1 if unknown) More... | |
Static Protected Attributes | |
static const int | bufsize = 1 << (Dim * twoPower - 3) |
The size of the buffer in bytes. More... | |
static const int | twoMask = ~0u >> (32 - twoPower) |
The mask for extracting one coordinate from the number. More... | |
static const int | width = 1 << twoPower |
The width of the set in each direction (in cubes). More... | |
static int | wrapping = 0 |
Wrapping in each direction. More... | |
A binary n-dimensional hypercube for storing cubes as bits.
The size of the hypercube is given as the power to which 2 is to be raised (e.g. 8 means the size of the side = 256).
|
inline |
The default constructor.
Definition at line 385 of file bincube.h.
|
inline |
The constructor to use a given memory buffer.
This memory buffer will not be released with delete[].
|
inline |
|
inline |
|
inline |
Sets the bit corresponding to the given cube (by number).
Note: The range of the coordinates is corrected if necessary.
Definition at line 590 of file bincube.h.
|
inline |
Sets the bit corresponding to the given cube (by number).
Warning: The range of the number is not verified.
Definition at line 580 of file bincube.h.
Referenced by chomp::homology::addneighbors().
|
inline |
Returns the iterator that points at the first cube in the set.
Definition at line 825 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::findcube().
Referenced by chomp::homology::reduceFullCubesAlg().
|
inline |
|
inline |
Checks if the given cube belongs to the set or not.
Warning: The range of the number is not verified.
Definition at line 567 of file bincube.h.
Referenced by chomp::homology::NeighborsBdd< cubetype, settype >::check(), chomp::homology::Acyclic1d< SetT >::check(), chomp::homology::Acyclic2d< SetT >::check(), chomp::homology::Acyclic3d< SetT >::check(), and chomp::homology::bincube< Dim, twoPower >::neighborhood_iterator::operator++().
|
inline |
Makes the set empty.
Definition at line 897 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::buf, chomp::homology::bincube< Dim, twoPower >::bufsize, and chomp::homology::bincube< Dim, twoPower >::cardinality.
|
inlinestatic |
Determines the number of the cube with given coordinates.
Verifies the range of the coordinates and uses wrapping.
Definition at line 478 of file bincube.h.
Referenced by chomp::homology::bit2neighborAlg(), and chomp::homology::bincube< Dim, twoPower >::neighborhood_iterator::operator++().
|
inline |
Get the number of cubes in the set.
Definition at line 868 of file bincube.h.
References chomp::homology::bitcountbyte(), chomp::homology::bincube< Dim, twoPower >::buf, chomp::homology::bincube< Dim, twoPower >::bufsize, chomp::homology::bincube< Dim, twoPower >::cardinality, and chomp::homology::bincube< Dim, twoPower >::end().
Referenced by chomp::homology::bincube< Dim, twoPower >::empty(), chomp::homology::bincube< Dim, twoPower >::operator int(), and chomp::homology::reduceFullCubesAlg().
|
inlinestatic |
Retrieves the dimension of the cube.
Definition at line 433 of file bincube.h.
Referenced by chomp::homology::reduceFullCubes().
|
inlinestatic |
Turns off wrapping in the given direction.
Definition at line 452 of file bincube.h.
|
inline |
Verifies whether the set is empty or not.
Definition at line 891 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::count().
Referenced by chomp::homology::reduceFullCubesAlg().
|
inline |
Returns the iterator that points beyond the end of the set.
Definition at line 832 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::maxcount.
Referenced by chomp::homology::addneighbors(), chomp::homology::bincube< Dim, twoPower >::count(), and chomp::homology::reduceFullCubesAlg().
|
inline |
Finds the first existing cube beginning at the given number.
The range of 'start' is not verified; must be >= 0, < maxcount. Returns the number of the cube found or maxcount if failed.
Definition at line 523 of file bincube.h.
Referenced by chomp::homology::bincube< Dim, twoPower >::begin(), and chomp::homology::bincube< Dim, twoPower >::iterator::operator++().
|
inline |
Gets the binary buffer for reading only.
Definition at line 840 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::buf.
|
inlinestatic |
Gets the buffer size.
Definition at line 852 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::bufsize.
Referenced by chomp::homology::operator<<().
|
inline |
Creates a neighborhood iterator for the specified cube and sets it at the first cube.
Definition at line 805 of file bincube.h.
Referenced by chomp::homology::addneighbors().
|
inline |
Creates a one-behind-the-end iterator for the given cube.
Definition at line 814 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::max_neighbors.
Referenced by chomp::homology::addneighbors().
|
inlinestatic |
|
inlinestatic |
Determines the coordinates of the cube with given number.
Definition at line 503 of file bincube.h.
Referenced by chomp::homology::bit2neighborAlg(), chomp::homology::bincube< Dim, twoPower >::iterator::coord(), and chomp::homology::bincube< Dim, twoPower >::neighborhood_iterator::neighborhood_iterator().
|
inline |
Gets the binary buffer for reading only.
Definition at line 846 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::buf.
|
inline |
Definition at line 885 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::count().
|
inline |
|
inline |
Reads the binary buffer from an input stream.
Definition at line 858 of file bincube.h.
References chomp::homology::bincube< Dim, twoPower >::buf, chomp::homology::bincube< Dim, twoPower >::bufsize, chomp::homology::bincube< Dim, twoPower >::cardinality, and chomp::homology::bincube< Dim, twoPower >::read().
Referenced by chomp::homology::operator>>(), and chomp::homology::bincube< Dim, twoPower >::read().
|
inline |
Clears the bit corresponding to the given cube (by number).
Note: The range of the coordinates is corrected if necessary.
Definition at line 606 of file bincube.h.
|
inline |
Clears the bit corresponding to the given cube (by number).
Warning: The range of the number is not verified.
Definition at line 596 of file bincube.h.
Referenced by chomp::homology::reduceFullCubesAlg().
|
inlinestatic |
Turns on wrapping in the given direction.
|
inlinestatic |
Wraps the coordinate in the given direction if necessary.
|
inlinestatic |
Verifies whether the space is wrapped in the given direction.
|
protected |
|
protected |
The memory for storing the hypercubes.
Definition at line 335 of file bincube.h.
Referenced by chomp::homology::bincube< Dim, twoPower >::clear(), chomp::homology::bincube< Dim, twoPower >::count(), chomp::homology::bincube< Dim, twoPower >::getbuffer(), chomp::homology::bincube< Dim, twoPower >::operator const char *(), and chomp::homology::bincube< Dim, twoPower >::read().
|
staticprotected |
The size of the buffer in bytes.
Definition at line 344 of file bincube.h.
Referenced by chomp::homology::bincube< Dim, twoPower >::clear(), chomp::homology::bincube< Dim, twoPower >::count(), chomp::homology::bincube< Dim, twoPower >::getbufsize(), and chomp::homology::bincube< Dim, twoPower >::read().
|
mutableprotected |
The number of cubes in the set (or -1 if unknown)
Definition at line 341 of file bincube.h.
Referenced by chomp::homology::bincube< Dim, twoPower >::clear(), chomp::homology::bincube< Dim, twoPower >::count(), and chomp::homology::bincube< Dim, twoPower >::read().
|
static |
The maximal possible number of neighbors of a cube.
Definition at line 200 of file bincube.h.
Referenced by chomp::homology::bincube< Dim, twoPower >::neighborhood_end().
|
static |
The maximal number of cubes that can be stored in the set.
Definition at line 331 of file bincube.h.
Referenced by chomp::homology::bincube< Dim, twoPower >::end().
|
static |
|
staticprotected |
|
staticprotected |
|
staticprotected |