DGtal 1.3.0
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions
DGtal::Labels< L, TWord > Class Template Reference

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, WordSelf
 
typedef unsigned int Label
 
typedef Label SizeType
 
typedef ConstEnumerator ConstIterator
 
typedef ConstIterator const_iterator
 

Public Member Functions

 ~Labels ()
 
 Labels ()
 
 Labels (const Self &other)
 
Selfoperator= (const Self &other)
 
bool test (Label l) const
 
Selfset (Label l, bool val=true)
 
Selfreset (Label l)
 
Selfflip (Label l)
 
Selfreset ()
 
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. More...
 
static SizeType _digit (Label l)
 Returns the bit at which is the label l. More...
 
static Word _mask (Label l)
 Returns the mask for the label l (1 << _digit( l )). More...
 

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. More...
 

Private Member Functions

 BOOST_STATIC_ASSERT ((L >=1))
 
 BOOST_CONCEPT_ASSERT ((concepts::CUnsignedNumber< TWord >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CIntegralNumber< TWord >))
 

Detailed Description

template<unsigned int L, typename TWord = DGtal::uint8_t>
class DGtal::Labels< L, 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.)

Template Parameters
Lis the maximum number of labels.
TWordthe integer used to store the labels (if L >= log_2( digits( TWord ) ) then several consecutive words are stored.)
See also
bitset

Definition at line 71 of file Labels.h.

Member Typedef Documentation

◆ const_iterator

template<unsigned int L, typename TWord = DGtal::uint8_t>
typedef ConstIterator DGtal::Labels< L, TWord >::const_iterator

Definition at line 198 of file Labels.h.

◆ ConstIterator

template<unsigned int L, typename TWord = DGtal::uint8_t>
typedef ConstEnumerator DGtal::Labels< L, TWord >::ConstIterator

Definition at line 197 of file Labels.h.

◆ Label

template<unsigned int L, typename TWord = DGtal::uint8_t>
typedef unsigned int DGtal::Labels< L, TWord >::Label

Definition at line 80 of file Labels.h.

◆ Self

template<unsigned int L, typename TWord = DGtal::uint8_t>
typedef Labels<L, Word> DGtal::Labels< L, TWord >::Self

Definition at line 79 of file Labels.h.

◆ SizeType

template<unsigned int L, typename TWord = DGtal::uint8_t>
typedef Label DGtal::Labels< L, TWord >::SizeType

Definition at line 81 of file Labels.h.

◆ Word

template<unsigned int L, typename TWord = DGtal::uint8_t>
typedef TWord DGtal::Labels< L, TWord >::Word

Definition at line 78 of file Labels.h.

Constructor & Destructor Documentation

◆ ~Labels()

template<unsigned int L, typename TWord = DGtal::uint8_t>
DGtal::Labels< L, TWord >::~Labels ( )

Destructor.

◆ Labels() [1/2]

template<unsigned int L, typename TWord = DGtal::uint8_t>
DGtal::Labels< L, TWord >::Labels ( )

Constructor.

◆ Labels() [2/2]

template<unsigned int L, typename TWord = DGtal::uint8_t>
DGtal::Labels< L, TWord >::Labels ( const Self other)

Copy constructor.

Parameters
otherthe object to clone.

Member Function Documentation

◆ _digit()

template<unsigned int L, typename TWord = DGtal::uint8_t>
static SizeType DGtal::Labels< L, TWord >::_digit ( Label  l)
staticprotected

Returns the bit at which is the label l.

◆ _mask()

template<unsigned int L, typename TWord = DGtal::uint8_t>
static Word DGtal::Labels< L, TWord >::_mask ( Label  l)
staticprotected

Returns the mask for the label l (1 << _digit( l )).

◆ _word()

template<unsigned int L, typename TWord = DGtal::uint8_t>
static SizeType DGtal::Labels< L, TWord >::_word ( Label  l)
staticprotected

Returns the word in which is the label l.

◆ begin()

template<unsigned int L, typename TWord = DGtal::uint8_t>
ConstIterator DGtal::Labels< L, TWord >::begin ( ) const
Returns
an iterator pointing on the first valid label.

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<unsigned int L, typename TWord = DGtal::uint8_t>
DGtal::Labels< L, TWord >::BOOST_CONCEPT_ASSERT ( (concepts::CIntegralNumber< TWord >)  )
private

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<unsigned int L, typename TWord = DGtal::uint8_t>
DGtal::Labels< L, TWord >::BOOST_CONCEPT_ASSERT ( (concepts::CUnsignedNumber< TWord >)  )
private

◆ BOOST_STATIC_ASSERT()

template<unsigned int L, typename TWord = DGtal::uint8_t>
DGtal::Labels< L, TWord >::BOOST_STATIC_ASSERT ( (L >=1)  )
private

◆ count()

template<unsigned int L, typename TWord = DGtal::uint8_t>
SizeType DGtal::Labels< L, TWord >::count ( ) const
Returns
the number of labels sets.

◆ end()

template<unsigned int L, typename TWord = DGtal::uint8_t>
ConstIterator DGtal::Labels< L, TWord >::end ( ) const
Returns
an iterator pointing after the last valid label.

◆ flip()

template<unsigned int L, typename TWord = DGtal::uint8_t>
Self & DGtal::Labels< L, TWord >::flip ( Label  l)

Flips l in or out of the set.

Parameters
lany label in 0..L-1
Returns
a reference on this.

◆ getLabels()

template<unsigned int L, typename TWord = DGtal::uint8_t>
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.

Parameters
labels(modified) the (ordered) labels set.

◆ index()

template<unsigned int L, typename TWord = DGtal::uint8_t>
SizeType DGtal::Labels< L, TWord >::index ( Label  l) const
Parameters
lany label in 0..L-1
Returns
the index of the label l in this set, starting from 0. If the label is not set, returns L (ie. size()).

◆ isValid()

template<unsigned int L, typename TWord = DGtal::uint8_t>
bool DGtal::Labels< L, TWord >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ operator=()

template<unsigned int L, typename TWord = DGtal::uint8_t>
Self & DGtal::Labels< L, TWord >::operator= ( const Self other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ reset() [1/2]

template<unsigned int L, typename TWord = DGtal::uint8_t>
Self & DGtal::Labels< L, TWord >::reset ( )

Clears the set.

Returns
a reference on this.

◆ reset() [2/2]

template<unsigned int L, typename TWord = DGtal::uint8_t>
Self & DGtal::Labels< L, TWord >::reset ( Label  l)

Removes l from the set.

Parameters
lany label in 0..L-1
Returns
a reference on this.

◆ selfDisplay()

template<unsigned int L, typename TWord = DGtal::uint8_t>
void DGtal::Labels< L, TWord >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ set()

template<unsigned int L, typename TWord = DGtal::uint8_t>
Self & DGtal::Labels< L, TWord >::set ( Label  l,
bool  val = true 
)

If val is true, inserts l in the set, otherwise removes it.

Parameters
lany label in 0..L-1
valeither true or false.
Returns
a reference on this.

◆ size()

template<unsigned int L, typename TWord = DGtal::uint8_t>
static SizeType DGtal::Labels< L, TWord >::size ( )
static
Returns
the total maximum possible number of labels sets, i.e. template parameter L.

◆ test()

template<unsigned int L, typename TWord = DGtal::uint8_t>
bool DGtal::Labels< L, TWord >::test ( Label  l) const
Parameters
lany label in 0..L-1
Returns
'true' iff this label is set.

Field Documentation

◆ myLabels

template<unsigned int L, typename TWord = DGtal::uint8_t>
Word DGtal::Labels< L, TWord >::myLabels[__DGTAL_LABELS_NBWORDS]
protected

Stores the labels as bits. The bit of index l is set if l is in the set.

Definition at line 91 of file Labels.h.


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