DGtal
0.6.devel
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
DGtal
base
Labels.h
1
17
#pragma once
18
31
#if defined(Labels_RECURSES)
32
#error Recursive header files inclusion detected in Labels.h
33
#else // defined(Labels_RECURSES)
34
35
#define Labels_RECURSES
36
37
#if !defined Labels_h
38
39
#define Labels_h
40
42
// Inclusions
43
#include <iostream>
44
#include <vector>
45
#include "DGtal/base/Common.h"
47
48
namespace
DGtal
49
{
50
52
// template class Labels
68
template
<
unsigned
int
L,
typename
TWord = DGtal::u
int
8_t>
69
class
Labels
70
{
71
BOOST_STATIC_ASSERT
(( L >= 1 ));
72
// BOOST_CONCEPT_ASSERT(( CUnsignedInteger<TWord> ));
73
74
public
:
75
typedef
TWord
Word
;
76
typedef
Labels<L, Word>
Self
;
77
typedef
unsigned
int
Label
;
78
typedef
Label
SizeType
;
79
80
#define __DGTAL_WORD_NBDIGITS ( sizeof( Word ) * 8 )
81
#define __DGTAL_LABELS_NBWORDS ( (L-1) / __DGTAL_WORD_NBDIGITS + 1 )
82
#define __DGTAL_LABEL_WORD_INDEX( label ) ( label / __DGTAL_WORD_NBDIGITS )
83
#define __DGTAL_LABEL_DIGIT_INDEX( label ) ( label % __DGTAL_WORD_NBDIGITS )
84
85
protected
:
86
88
Word
myLabels
[ __DGTAL_LABELS_NBWORDS ];
89
91
static
SizeType
_word
(
Label
l );
93
static
SizeType
_digit
(
Label
l );
95
static
Word
_mask
(
Label
l );
96
97
public
:
102
class
ConstEnumerator
{
103
public
:
104
typedef
ConstEnumerator
Self
;
105
typedef
Label
Value
;
106
typedef
const
Value
*
Pointer
;
107
typedef
const
Value
&
Reference
;
108
typedef
std::ptrdiff_t
DifferenceType
;
//< only positive offsets allowed.
109
110
// ----------------------- std types ----------------------------------
111
typedef
Value
value_type
;
112
typedef
std::size_t
size_type
;
113
typedef
DifferenceType
difference_type
;
114
typedef
Pointer
pointer
;
115
typedef
Reference
reference
;
116
typedef
std::forward_iterator_tag
iterator_category
;
117
118
private
:
119
const
Word
*
myWordAddress
;
//< current address of word
120
Label
myWordLabel
;
//< index of first label of the current word.
121
Label
myLabel
;
//< current label
122
Word
myWord
;
//< current word (modified until 0).
123
124
public
:
128
~ConstEnumerator
();
129
133
ConstEnumerator
();
134
140
ConstEnumerator
(
const
Word
* address,
SizeType
firstWord );
141
146
ConstEnumerator
(
const
ConstEnumerator
& other );
147
153
Self
&
operator=
(
const
Self
& other );
154
159
Reference
operator*
()
const
;
160
165
Pointer
operator->
()
const
;
166
171
Self
&
operator++
();
176
Self
operator++
(
int
);
177
183
bool
operator==
(
const
Self
& other )
const
;
184
190
bool
operator!=
(
const
Self
& other )
const
;
191
192
};
193
194
typedef
ConstEnumerator
ConstIterator
;
195
typedef
ConstIterator
const_iterator
;
196
197
// ----------------------- Standard services ------------------------------
198
public
:
199
203
~Labels
();
204
208
Labels
();
209
214
Labels
(
const
Self
& other );
215
221
Self
&
operator=
(
const
Self
& other );
222
227
bool
test
(
Label
l )
const
;
228
229
// bitset<N>& set ( );
230
// bitset<N>& reset ( );
231
238
Self
&
set
(
Label
l,
bool
val = true );
239
245
Self
&
reset
(
Label
l );
246
252
Self
&
flip
(
Label
l );
253
258
Self
&
reset
();
259
263
SizeType
count
()
const
;
264
269
static
SizeType
size
();
270
277
void
getLabels
( std::vector<Label> & labels )
const
;
278
283
SizeType
index
(
Label
l )
const
;
284
288
ConstIterator
begin
()
const
;
289
293
ConstIterator
end
()
const
;
294
295
// ----------------------- Interface --------------------------------------
296
public
:
297
302
void
selfDisplay
( std::ostream & out )
const
;
303
308
bool
isValid
()
const
;
309
310
// ------------------------- Protected Datas ------------------------------
311
private
:
312
// ------------------------- Private Datas --------------------------------
313
private
:
314
315
// ------------------------- Hidden services ------------------------------
316
protected
:
317
318
319
// ------------------------- Internals ------------------------------------
320
private
:
321
322
};
// end of class Labels
323
324
331
template
<
unsigned
int
L,
typename
TWord>
332
std::ostream&
333
operator<< ( std::ostream & out, const Labels<L, TWord> & object );
334
335
}
// namespace DGtal
336
337
339
// Includes inline functions.
340
#include "DGtal/base/Labels.ih"
341
342
// //
344
345
#endif // !defined Labels_h
346
347
#undef Labels_RECURSES
348
#endif // else defined(Labels_RECURSES)
Generated on Wed Dec 19 2012 19:10:28 for DGtal by
1.8.1.1