DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Labels.h
1
16
17
#pragma once
18
30
31
#if defined(Labels_RECURSES)
32
#error Recursive header files inclusion detected in Labels.h
33
#else
// defined(Labels_RECURSES)
35
#define Labels_RECURSES
36
37
#if !defined Labels_h
39
#define Labels_h
40
42
// Inclusions
43
#include <iostream>
44
#include <vector>
45
#include "DGtal/base/Common.h"
46
#include "DGtal/kernel/CUnsignedNumber.h"
47
#include "DGtal/kernel/CIntegralNumber.h"
49
50
namespace
DGtal
51
{
52
54
// template class Labels
70
template
<
unsigned
int
L,
typename
TWord = DGtal::u
int
8_t>
71
class
Labels
72
{
73
BOOST_STATIC_ASSERT
(( L >= 1 ));
74
BOOST_CONCEPT_ASSERT
((
concepts::CUnsignedNumber<TWord>
));
75
BOOST_CONCEPT_ASSERT
((
concepts::CIntegralNumber<TWord>
));
76
77
public
:
78
typedef
TWord
Word
;
79
typedef
Labels<L, Word>
Self
;
80
typedef
unsigned
int
Label
;
81
typedef
Label
SizeType
;
82
83
#define __DGTAL_WORD_NBDIGITS ( sizeof( Word ) * 8 )
84
#define __DGTAL_LABELS_NBWORDS ( (L-1) / __DGTAL_WORD_NBDIGITS + 1 )
85
#define __DGTAL_LABEL_WORD_INDEX( label ) ( label / __DGTAL_WORD_NBDIGITS )
86
#define __DGTAL_LABEL_DIGIT_INDEX( label ) ( label % __DGTAL_WORD_NBDIGITS )
87
88
protected
:
89
91
Word
myLabels
[ __DGTAL_LABELS_NBWORDS ];
92
94
static
SizeType
_word
(
Label
l );
96
static
SizeType
_digit
(
Label
l );
98
static
Word
_mask
(
Label
l );
99
100
public
:
105
class
ConstEnumerator
{
106
public
:
107
typedef
ConstEnumerator
Self
;
108
typedef
Label
Value
;
109
typedef
const
Value
*
Pointer
;
110
typedef
const
Value
&
Reference
;
111
typedef
std::ptrdiff_t
DifferenceType
;
112
113
// ----------------------- std types ----------------------------------
114
typedef
Value
value_type
;
115
typedef
std::size_t
size_type
;
116
typedef
DifferenceType
difference_type
;
117
typedef
Pointer
pointer
;
118
typedef
Reference
reference
;
119
typedef
std::forward_iterator_tag
iterator_category
;
120
121
private
:
122
const
Word
*
myWordAddress
;
123
Label
myWordLabel
;
124
Label
myLabel
;
125
Word
myWord
;
126
127
public
:
131
~ConstEnumerator
();
132
136
ConstEnumerator
();
137
143
ConstEnumerator
(
const
Word
* address,
SizeType
firstWord );
144
149
ConstEnumerator
(
const
ConstEnumerator
& other );
150
156
Self
&
operator=
(
const
Self
& other );
157
162
Reference
operator*
()
const
;
163
168
Pointer
operator->
()
const
;
169
174
Self
&
operator++
();
179
Self
operator++
(
int
);
180
186
bool
operator==
(
const
Self
& other )
const
;
187
193
bool
operator!=
(
const
Self
& other )
const
;
194
195
};
196
197
typedef
ConstEnumerator
ConstIterator
;
198
typedef
ConstIterator
const_iterator
;
199
200
// ----------------------- Standard services ------------------------------
201
public
:
202
206
~Labels
();
207
211
Labels
();
212
217
Labels
(
const
Self
& other );
218
224
Self
&
operator=
(
const
Self
& other );
225
230
bool
test
(
Label
l )
const
;
231
232
// bitset<N>& set ( );
233
// bitset<N>& reset ( );
234
241
Self
&
set
(
Label
l,
bool
val =
true
);
242
248
Self
&
reset
(
Label
l );
249
255
Self
&
flip
(
Label
l );
256
261
Self
&
reset
();
262
266
SizeType
count
()
const
;
267
272
static
SizeType
size
();
273
280
void
getLabels
( std::vector<Label> & labels )
const
;
281
286
SizeType
index
(
Label
l )
const
;
287
291
ConstIterator
begin
()
const
;
292
296
ConstIterator
end
()
const
;
297
298
// ----------------------- Interface --------------------------------------
299
public
:
300
305
void
selfDisplay
( std::ostream & out )
const
;
306
311
bool
isValid
()
const
;
312
313
// ------------------------- Protected Data ------------------------------
314
private
:
315
// ------------------------- Private Data --------------------------------
316
private
:
317
318
// ------------------------- Hidden services ------------------------------
319
protected
:
320
321
322
// ------------------------- Internals ------------------------------------
323
private
:
324
325
};
// end of class Labels
326
327
334
template
<
unsigned
int
L,
typename
TWord>
335
std::ostream&
336
operator<<
( std::ostream & out,
const
Labels<L, TWord>
&
object
);
337
338
}
// namespace DGtal
339
340
342
// Includes inline functions.
343
#include "DGtal/base/Labels.ih"
344
345
// //
347
348
#endif
// !defined Labels_h
349
350
#undef Labels_RECURSES
351
#endif
// else defined(Labels_RECURSES)
DGtal::Labels::ConstEnumerator::pointer
Pointer pointer
Definition
Labels.h:117
DGtal::Labels::ConstEnumerator::DifferenceType
std::ptrdiff_t DifferenceType
only positive offsets allowed.
Definition
Labels.h:111
DGtal::Labels::ConstEnumerator::operator!=
bool operator!=(const Self &other) const
DGtal::Labels::ConstEnumerator::operator*
Reference operator*() const
DGtal::Labels::ConstEnumerator::operator->
Pointer operator->() const
DGtal::Labels::ConstEnumerator::Self
ConstEnumerator Self
Definition
Labels.h:107
DGtal::Labels::ConstEnumerator::operator=
Self & operator=(const Self &other)
DGtal::Labels::ConstEnumerator::ConstEnumerator
ConstEnumerator()
DGtal::Labels::ConstEnumerator::size_type
std::size_t size_type
Definition
Labels.h:115
DGtal::Labels::ConstEnumerator::reference
Reference reference
Definition
Labels.h:118
DGtal::Labels::ConstEnumerator::~ConstEnumerator
~ConstEnumerator()
DGtal::Labels::ConstEnumerator::myWordAddress
const Word * myWordAddress
current address of word
Definition
Labels.h:122
DGtal::Labels::ConstEnumerator::Pointer
const Value * Pointer
Definition
Labels.h:109
DGtal::Labels::ConstEnumerator::Reference
const Value & Reference
Definition
Labels.h:110
DGtal::Labels::ConstEnumerator::difference_type
DifferenceType difference_type
Definition
Labels.h:116
DGtal::Labels::ConstEnumerator::ConstEnumerator
ConstEnumerator(const Word *address, SizeType firstWord)
DGtal::Labels::ConstEnumerator::myWord
Word myWord
current word (modified until 0).
Definition
Labels.h:125
DGtal::Labels::ConstEnumerator::operator++
Self & operator++()
DGtal::Labels::ConstEnumerator::myLabel
Label myLabel
current label
Definition
Labels.h:124
DGtal::Labels::ConstEnumerator::operator==
bool operator==(const Self &other) const
DGtal::Labels::ConstEnumerator::value_type
Value value_type
Definition
Labels.h:114
DGtal::Labels::ConstEnumerator::myWordLabel
Label myWordLabel
index of first label of the current word.
Definition
Labels.h:123
DGtal::Labels::ConstEnumerator::iterator_category
std::forward_iterator_tag iterator_category
Definition
Labels.h:119
DGtal::Labels::ConstEnumerator::Value
Label Value
Definition
Labels.h:108
DGtal::Labels::ConstEnumerator::operator++
Self operator++(int)
DGtal::Labels::ConstEnumerator::ConstEnumerator
ConstEnumerator(const ConstEnumerator &other)
DGtal::Labels
Aim: Stores a set of labels in {O..L-1} as a sequence of bits.
Definition
Labels.h:72
DGtal::Labels::end
ConstIterator end() const
DGtal::Labels::_digit
static SizeType _digit(Label l)
Returns the bit at which is the label l.
DGtal::Labels::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CUnsignedNumber< TWord >))
DGtal::Labels::Labels
Labels()
DGtal::Labels< L, Word >::const_iterator
ConstIterator const_iterator
Definition
Labels.h:198
DGtal::Labels::count
SizeType count() const
DGtal::Labels< L, Word >::Word
Word Word
Definition
Labels.h:78
DGtal::Labels< L, Word >::Self
Labels< L, Word > Self
Definition
Labels.h:79
DGtal::Labels::isValid
bool isValid() const
DGtal::Labels::reset
Self & reset()
DGtal::Labels< L, Word >::SizeType
Label SizeType
Definition
Labels.h:81
DGtal::Labels::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::Labels::test
bool test(Label l) const
DGtal::Labels::index
SizeType index(Label l) const
DGtal::Labels< L, Word >::Label
unsigned int Label
Definition
Labels.h:80
DGtal::Labels::begin
ConstIterator begin() const
DGtal::Labels< L, Word >::ConstIterator
ConstEnumerator ConstIterator
Definition
Labels.h:197
DGtal::Labels::operator=
Self & operator=(const Self &other)
DGtal::Labels< L, Word >::myLabels
Word myLabels[__DGTAL_LABELS_NBWORDS]
Definition
Labels.h:91
DGtal::Labels::size
static SizeType size()
DGtal::Labels::~Labels
~Labels()
DGtal::Labels::flip
Self & flip(Label l)
DGtal::Labels::getLabels
void getLabels(std::vector< Label > &labels) const
DGtal::Labels::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CIntegralNumber< TWord >))
DGtal::Labels::_word
static SizeType _word(Label l)
Returns the word in which is the label l.
DGtal::Labels::set
Self & set(Label l, bool val=true)
DGtal::Labels::_mask
static Word _mask(Label l)
Returns the mask for the label l (1 << _digit( l )).
DGtal::Labels::Labels
Labels(const Self &other)
DGtal::Labels::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((L >=1))
DGtal::Labels::reset
Self & reset(Label l)
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::concepts::CIntegralNumber
Aim: Concept checking for Integral Numbers. Models of this concept should be listed in NumberTraits c...
Definition
CIntegralNumber.h:102
DGtal::concepts::CUnsignedNumber
Aim: Concept checking for Unsigned numbers. Models of this concept should be listed in NumberTraits c...
Definition
CUnsignedNumber.h:95
src
DGtal
base
Labels.h
Generated on
for DGtal by
1.18.0