DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Private Attributes
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 &out, unsigned int l, unsigned int x, unsigned int y)
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 75 of file testLabelledMap-benchmark.cpp.


Constructor & Destructor Documentation

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

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

{
_invalid = invalid;
clear();
}

Member Function Documentation

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 149 of file testLabelledMap-benchmark.cpp.

{
return L * X * Y * sizeof( Value );
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y>
void ArrayLXY< Value, L, X, Y >::clear ( )
inline

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

{
for ( unsigned int l = 0; l < L; ++l )
for ( unsigned int y = 0; y < Y; ++y )
for ( unsigned int x = 0; x < X; ++x )
setValue( _invalid, l, x, y );
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y>
void ArrayLXY< Value, L, X, Y >::display ( ostream &  out,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

{}
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 102 of file testLabelledMap-benchmark.cpp.

{
if ( _data[ l ][ x ][ y ] != _invalid )
{
_data[ l ][ x ][ y ] = _invalid;
return 1;
}
return 0;
}
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 128 of file testLabelledMap-benchmark.cpp.

{
labels.clear();
for ( unsigned int l = 0; l < L; ++l )
if ( hasLabel( l, x, y ) )
labels.push_back( l );
}
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 123 of file testLabelledMap-benchmark.cpp.

{
return value( l, x, y ) != _invalid;
}
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 137 of file testLabelledMap-benchmark.cpp.

{
unsigned int nb = 0;
for ( unsigned int l = 0; l < L; ++l )
if ( hasLabel( l, x, y ) ) ++nb;
return nb;
}
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 113 of file testLabelledMap-benchmark.cpp.

{
_data[ l ][ x ][ y ] = val;
}
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 118 of file testLabelledMap-benchmark.cpp.

{
_data[ l ][ x ][ y ] = val;
}
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 97 of file testLabelledMap-benchmark.cpp.

{
return _data[ l ][ x ][ y ];
}

Field Documentation

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 76 of file testLabelledMap-benchmark.cpp.

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

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


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