DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Data Fields | Private Attributes
DynArrayLXY< Value > Class Template Reference

Public Types

typedef Value ValueType

Public Member Functions

 DynArrayLXY (unsigned int _L, unsigned int _X, unsigned int _Y, Value invalid)
 ~DynArrayLXY ()
void clear ()
size_t offset (unsigned int l, unsigned int x, unsigned int y) const
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

Data Fields

const unsigned int L
const unsigned int X
const unsigned int Y

Private Attributes

Value * _data
Value _invalid

Detailed Description

template<typename Value>
class DynArrayLXY< Value >

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 79 of file testMultiMap-benchmark.cpp.


Member Typedef Documentation

template<typename Value >
typedef Value DynArrayLXY< Value >::ValueType

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


Constructor & Destructor Documentation

template<typename Value >
DynArrayLXY< Value >::DynArrayLXY ( unsigned int  _L,
unsigned int  _X,
unsigned int  _Y,
Value  invalid 
)
inline

Definition at line 92 of file testMultiMap-benchmark.cpp.

: L( _L ), X( _X ), Y( _Y )
{
_invalid = invalid;
_data = new Value[ L * X * Y ];
clear();
}
template<typename Value >
DynArrayLXY< Value >::~DynArrayLXY ( )
inline

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

{
delete[] _data;
}

Member Function Documentation

template<typename Value >
unsigned long long DynArrayLXY< Value >::area ( ) const
inline

Definition at line 172 of file testMultiMap-benchmark.cpp.

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

Definition at line 105 of file testMultiMap-benchmark.cpp.

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

Definition at line 168 of file testMultiMap-benchmark.cpp.

{}
template<typename Value >
unsigned int DynArrayLXY< Value >::erase ( unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

Definition at line 124 of file testMultiMap-benchmark.cpp.

{
size_t offs = offset( l, x, y );
if ( _data[ offs ] != _invalid )
{
_data[ offs ] = _invalid;
return 1;
}
return 0;
}
template<typename Value >
void DynArrayLXY< Value >::getLabels ( std::vector< unsigned int > &  labels,
unsigned int  x,
unsigned int  y 
) const
inline

Definition at line 151 of file testMultiMap-benchmark.cpp.

{
labels.clear();
for ( unsigned int l = 0; l < L; ++l )
if ( hasLabel( l, x, y ) )
labels.push_back( l );
}
template<typename Value >
bool DynArrayLXY< Value >::hasLabel ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

Definition at line 146 of file testMultiMap-benchmark.cpp.

{
return value( l, x, y ) != _invalid;
}
template<typename Value >
unsigned int DynArrayLXY< Value >::nbLabels ( unsigned int  x,
unsigned int  y 
) const
inline

Definition at line 160 of file testMultiMap-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 >
size_t DynArrayLXY< Value >::offset ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

Definition at line 114 of file testMultiMap-benchmark.cpp.

{
return ( ( l * X ) + x ) * Y + y;
}
template<typename Value >
void DynArrayLXY< Value >::setValue ( const Value &  val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

Definition at line 136 of file testMultiMap-benchmark.cpp.

{
_data[ offset( l, x, y ) ] = val;
}
template<typename Value >
void DynArrayLXY< Value >::setValueNoNewLabel ( const Value &  val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

Definition at line 141 of file testMultiMap-benchmark.cpp.

{
_data[ offset( l, x, y ) ] = val;
}
template<typename Value >
const Value& DynArrayLXY< Value >::value ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

Definition at line 119 of file testMultiMap-benchmark.cpp.

{
return _data[ offset( l, x, y ) ];
}

Field Documentation

template<typename Value >
Value* DynArrayLXY< Value >::_data
private

Definition at line 87 of file testMultiMap-benchmark.cpp.

template<typename Value >
Value DynArrayLXY< Value >::_invalid
private

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

template<typename Value >
const unsigned int DynArrayLXY< Value >::L

Definition at line 82 of file testMultiMap-benchmark.cpp.

template<typename Value >
const unsigned int DynArrayLXY< Value >::X

Definition at line 83 of file testMultiMap-benchmark.cpp.

template<typename Value >
const unsigned int DynArrayLXY< Value >::Y

Definition at line 84 of file testMultiMap-benchmark.cpp.


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