DGtal 1.4.0
|
Aim: Stores a set of labels in {O..L-1} as a sequence of bits. More...
#include <DGtal/base/Labels.h>
Data Structures | |
class | ConstEnumerator |
Public Types | |
typedef TWord | Word |
typedef Labels< L, Word > | Self |
typedef unsigned int | Label |
typedef Label | SizeType |
typedef ConstEnumerator | ConstIterator |
typedef ConstIterator | const_iterator |
Public Member Functions | |
~Labels () | |
Labels () | |
Labels (const Self &other) | |
Self & | operator= (const Self &other) |
bool | test (Label l) const |
Self & | set (Label l, bool val=true) |
Self & | reset (Label l) |
Self & | flip (Label l) |
Self & | reset () |
SizeType | count () const |
void | getLabels (std::vector< Label > &labels) const |
SizeType | index (Label l) const |
ConstIterator | begin () const |
ConstIterator | end () const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Static Public Member Functions | |
static SizeType | size () |
Static Protected Member Functions | |
static SizeType | _word (Label l) |
Returns the word in which is the label l. | |
static SizeType | _digit (Label l) |
Returns the bit at which is the label l. | |
static Word | _mask (Label l) |
Returns the mask for the label l (1 << _digit( l )). | |
Protected Attributes | |
Word | myLabels [__DGTAL_LABELS_NBWORDS] |
Stores the labels as bits. The bit of index l is set if l is in the set. | |
Private Member Functions | |
BOOST_STATIC_ASSERT ((L >=1)) | |
BOOST_CONCEPT_ASSERT ((concepts::CUnsignedNumber< TWord >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CIntegralNumber< TWord >)) | |
Aim: Stores a set of labels in {O..L-1} as a sequence of bits.
Description of template class 'Labels'
This class is useful to stores a set of numbers as a characteristic set. It is very similar to a bitset, except it provides more functions, like giving the index of a label (i.e., if (1, 5, 6, 13, 20) are the labels, then 1 has index 0, 5 has index 1, 6 has index 2, 13 has index 3, 20 has index 4.)
L | is the maximum number of labels. |
TWord | the integer used to store the labels (if L >= log_2( digits( TWord ) ) then several consecutive words are stored.) |
typedef ConstIterator DGtal::Labels< L, TWord >::const_iterator |
typedef ConstEnumerator DGtal::Labels< L, TWord >::ConstIterator |
typedef unsigned int DGtal::Labels< L, TWord >::Label |
typedef Labels<L, Word> DGtal::Labels< L, TWord >::Self |
typedef Label DGtal::Labels< L, TWord >::SizeType |
typedef TWord DGtal::Labels< L, TWord >::Word |
DGtal::Labels< L, TWord >::~Labels | ( | ) |
Destructor.
DGtal::Labels< L, TWord >::Labels | ( | ) |
Constructor.
DGtal::Labels< L, TWord >::Labels | ( | const Self & | other | ) |
Copy constructor.
other | the object to clone. |
|
staticprotected |
Returns the bit at which is the label l.
|
staticprotected |
Returns the mask for the label l (1 << _digit( l )).
|
staticprotected |
Returns the word in which is the label l.
ConstIterator DGtal::Labels< L, TWord >::begin | ( | ) | const |
|
private |
|
private |
|
private |
SizeType DGtal::Labels< L, TWord >::count | ( | ) | const |
ConstIterator DGtal::Labels< L, TWord >::end | ( | ) | const |
Self & DGtal::Labels< L, TWord >::flip | ( | Label | l | ) |
Flips l in or out of the set.
l | any label in 0..L-1 |
void DGtal::Labels< L, TWord >::getLabels | ( | std::vector< Label > & | labels | ) | const |
As output, labels[0] contains the label of index 0, labels[1] the label of index 1, and so on.
labels | (modified) the (ordered) labels set. |
SizeType DGtal::Labels< L, TWord >::index | ( | Label | l | ) | const |
l | any label in 0..L-1 |
bool DGtal::Labels< L, TWord >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Self & DGtal::Labels< L, TWord >::operator= | ( | const Self & | other | ) |
Assignment.
other | the object to copy. |
Self & DGtal::Labels< L, TWord >::reset | ( | ) |
Clears the set.
Self & DGtal::Labels< L, TWord >::reset | ( | Label | l | ) |
Removes l from the set.
l | any label in 0..L-1 |
void DGtal::Labels< L, TWord >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Self & DGtal::Labels< L, TWord >::set | ( | Label | l, |
bool | val = true ) |
If val is true, inserts l in the set, otherwise removes it.
l | any label in 0..L-1 |
val | either true or false. |
|
static |
bool DGtal::Labels< L, TWord >::test | ( | Label | l | ) | const |
l | any label in 0..L-1 |
|
protected |