DGtal 2.2.0
Loading...
Searching...
No Matches
ArrayLXY< Value, L, X, Y > Class Template Reference

Public Member Functions

 ArrayLXY (Value invalid)
void clear ()
const Value & value (unsigned int l, unsigned int x, unsigned int y) const
unsigned int erase (unsigned int l, unsigned int x, unsigned int y)
void setValue (const Value &val, unsigned int l, unsigned int x, unsigned int y)
void setValueNoNewLabel (const Value &val, unsigned int l, unsigned int x, unsigned int y)
bool hasLabel (unsigned int l, unsigned int x, unsigned int y) const
void getLabels (std::vector< unsigned int > &labels, unsigned int x, unsigned int y) const
unsigned int nbLabels (unsigned int x, unsigned int y) const
void display (ostream &, unsigned int, unsigned int, unsigned int)
unsigned long long area () const

Private Attributes

Value _data [L][X][Y]
Value _invalid

Detailed Description

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
class ArrayLXY< Value, L, X, Y >

Array[L][X][Y] of value. Brute-force. High memory consumption. Rather fast except when working with several labels.

Note that 4000*4000*16 is upper limit on my 8Gb laptop (2Gb). Note that 2000*2000*64 is upper limit on my 8Gb laptop (2Gb).

Definition at line 73 of file testLabelledMap-benchmark.cpp.

Constructor & Destructor Documentation

◆ ArrayLXY()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
ArrayLXY< Value, L, X, Y >::ArrayLXY ( Value invalid)
inline

Definition at line 79 of file testLabelledMap-benchmark.cpp.

References _invalid, and clear().

Member Function Documentation

◆ area()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
unsigned long long ArrayLXY< Value, L, X, Y >::area ( ) const
inline

Definition at line 147 of file testLabelledMap-benchmark.cpp.

148 {
149 return L * X * Y * sizeof( Value );
150 }

References DGtal::L.

◆ clear()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
void ArrayLXY< Value, L, X, Y >::clear ( )
inline

Definition at line 86 of file testLabelledMap-benchmark.cpp.

87 {
88 for ( unsigned int l = 0; l < L; ++l )
89 for ( unsigned int y = 0; y < Y; ++y )
90 for ( unsigned int x = 0; x < X; ++x )
91 setValue( _invalid, l, x, y );
92 }
void setValue(const Value &val, unsigned int l, unsigned int x, unsigned int y)

References _invalid, DGtal::L, and setValue().

Referenced by ArrayLXY().

◆ display()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
void ArrayLXY< Value, L, X, Y >::display ( ostream & ,
unsigned int ,
unsigned int ,
unsigned int  )
inline

Definition at line 143 of file testLabelledMap-benchmark.cpp.

144 {}

◆ erase()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
unsigned int ArrayLXY< Value, L, X, Y >::erase ( unsigned int l,
unsigned int x,
unsigned int y )
inline

Definition at line 100 of file testLabelledMap-benchmark.cpp.

101 {
102 if ( _data[ l ][ x ][ y ] != _invalid )
103 {
104 _data[ l ][ x ][ y ] = _invalid;
105 return 1;
106 }
107 return 0;
108 }

References _data, and _invalid.

◆ getLabels()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
void ArrayLXY< Value, L, X, Y >::getLabels ( std::vector< unsigned int > & labels,
unsigned int x,
unsigned int y ) const
inline

Definition at line 126 of file testLabelledMap-benchmark.cpp.

128 {
129 labels.clear();
130 for ( unsigned int l = 0; l < L; ++l )
131 if ( hasLabel( l, x, y ) )
132 labels.push_back( l );
133 }
bool hasLabel(unsigned int l, unsigned int x, unsigned int y) const

References hasLabel(), and DGtal::L.

◆ hasLabel()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
bool ArrayLXY< Value, L, X, Y >::hasLabel ( unsigned int l,
unsigned int x,
unsigned int y ) const
inline

Definition at line 121 of file testLabelledMap-benchmark.cpp.

122 {
123 return value( l, x, y ) != _invalid;
124 }
const Value & value(unsigned int l, unsigned int x, unsigned int y) const

References _invalid, and value().

Referenced by getLabels(), and nbLabels().

◆ nbLabels()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
unsigned int ArrayLXY< Value, L, X, Y >::nbLabels ( unsigned int x,
unsigned int y ) const
inline

Definition at line 135 of file testLabelledMap-benchmark.cpp.

136 {
137 unsigned int nb = 0;
138 for ( unsigned int l = 0; l < L; ++l )
139 if ( hasLabel( l, x, y ) ) ++nb;
140 return nb;
141 }

References hasLabel(), and DGtal::L.

◆ setValue()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
void ArrayLXY< Value, L, X, Y >::setValue ( const Value & val,
unsigned int l,
unsigned int x,
unsigned int y )
inline

Definition at line 111 of file testLabelledMap-benchmark.cpp.

112 {
113 _data[ l ][ x ][ y ] = val;
114 }

References _data.

Referenced by clear().

◆ setValueNoNewLabel()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
void ArrayLXY< Value, L, X, Y >::setValueNoNewLabel ( const Value & val,
unsigned int l,
unsigned int x,
unsigned int y )
inline

Definition at line 116 of file testLabelledMap-benchmark.cpp.

117 {
118 _data[ l ][ x ][ y ] = val;
119 }

References _data.

◆ value()

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
const Value & ArrayLXY< Value, L, X, Y >::value ( unsigned int l,
unsigned int x,
unsigned int y ) const
inline

Definition at line 95 of file testLabelledMap-benchmark.cpp.

96 {
97 return _data[ l ][ x ][ y ];
98 }

References _data.

Referenced by hasLabel().

Field Documentation

◆ _data

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
Value ArrayLXY< Value, L, X, Y >::_data[L][X][Y]
private

Definition at line 74 of file testLabelledMap-benchmark.cpp.

Referenced by erase(), setValue(), setValueNoNewLabel(), and value().

◆ _invalid

template<typename Value, unsigned int L, unsigned int X, unsigned int Y>
Value ArrayLXY< Value, L, X, Y >::_invalid
private

Definition at line 75 of file testLabelledMap-benchmark.cpp.

Referenced by ArrayLXY(), clear(), erase(), and hasLabel().


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