rcolyer.net
RC Lib  Version 202403231100
Public Member Functions | Friends | List of all members
RC::Bitfield3D Class Reference

A bounds-safe three-dimensional structure of efficiently packed bits. More...

#include <Bitfield3D.h>

Public Member Functions

 Bitfield3D ()
 Default constructor which initializes to size 0, 0, 0.
 
 Bitfield3D (size_t b_size1, size_t b_size2, size_t b_size3)
 Cosntructor which sets the initial sizes. More...
 
void Delete ()
 Deletes the stored data, resets the sizes to 0, and releases the memory.
 
bool IsEmpty () const
 True of the total size of the bits is 0.
 
Bitfield::BitfieldBool operator() (size_t x, size_t y, size_t z)
 Bounds-checked access of the indexed element. More...
 
Bitfield::BitfieldBoolConst operator() (size_t x, size_t y, size_t z) const
 Const version of operator()
 
Bitfield::BitfieldBool At (size_t x, size_t y, size_t z)
 Identical to operator()
 
Bitfield::BitfieldBoolConst At (size_t x, size_t y, size_t z) const
 Const version of At()
 
size_t size1 () const
 Return the extent in bits of dimension 1.
 
size_t size2 () const
 Return the extent in bits of dimension 2.
 
size_t size3 () const
 Return the extent in bits of dimension 3.
 
void Zero ()
 Set all bits to 0 / false.
 
void Zero2D (const size_t z)
 Set all bits of dimensions 1 and 2 to zero at z indexed dimension 3.
 
void Zero1D (const size_t y, const size_t z)
 Set all bits of dimension 1 to zero at y and z indexed dimensions 2 and 3.
 
bool Check (const size_t x, const size_t y, const size_t z) const
 True of indices x, y, and z are all in bounds.
 
void Assert (const size_t x, const size_t y, const size_t z) const
 Throws ErrorMsgBounds if index x, y, or z is out of bounds.
 

Friends

void swap (Bitfield3D &a, Bitfield3D &b)
 Swap the data in Bitfield3D a and b.
 

Detailed Description

A bounds-safe three-dimensional structure of efficiently packed bits.

Note AxBxC dimensions take ABC bits of storage with the total rounded up to the nearest 32 bit word.

See also
Bitfield
Bitfield2D

Constructor & Destructor Documentation

◆ Bitfield3D()

RC::Bitfield3D::Bitfield3D ( size_t  b_size1,
size_t  b_size2,
size_t  b_size3 
)
inlineexplicit

Cosntructor which sets the initial sizes.

Efficiency note: the first dimension, set by b_size1, should be the one which is iterated over most frequently in innermost loops for caching gains.

Parameters
b_size1The size of the first dimension.
b_size2The size of the second dimension.
b_size3The size of the third dimension.

Member Function Documentation

◆ operator()()

Bitfield::BitfieldBool RC::Bitfield3D::operator() ( size_t  x,
size_t  y,
size_t  z 
)
inline

Bounds-checked access of the indexed element.

Throws an ErrorMsgBounds exception if x, y, or z is out of the bounds.

Parameters
xThe dimension 1 index of the bit to access.
yThe dimension 2 index of the bit to access.
zThe dimension 3 index of the bit to access.
Returns
A Bitfield::BitfieldBool structure that casts to a bool or can be assigned a bool value.

The documentation for this class was generated from the following file:
email address
— (c) 2015