DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Private Types | Private Attributes
ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M > Class Template Reference
Collaboration diagram for ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >:
Collaboration graph
[legend]

Public Member Functions

 ArrayXYOfLabelledMap ()
const Value & value (unsigned int l, unsigned int x, unsigned int y) const
void setValue (const Value &val, unsigned int l, unsigned int x, unsigned int y)
unsigned int erase (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 Types

typedef LabelledMap< Value, L,
TWord, N, M > 
MyLabelledMap

Private Attributes

MyLabelledMap _data [X][Y]

Detailed Description

template<typename Value, unsigned int L, unsigned int X, unsigned int Y, typename TWord, unsigned int N, unsigned int M>
class ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >

Array[X][Y] of LabelledMap<L>

The proposed alternative to the brute-force approach. Generally less than 10 times the memory used by brute force for L >= 16. Approximately 50% slower in most operations, except initialization or used of all labels. In this case outperforms Array[L][X][Y].

Note that 4000*4000*16 is fine on my 8Gb laptop (529Mb). Note that 2000*2000*64 takes 133Mb.

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


Member Typedef Documentation

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
typedef LabelledMap< Value, L, TWord, N, M> ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::MyLabelledMap
private

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


Constructor & Destructor Documentation

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::ArrayXYOfLabelledMap ( )
inline

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

{}

Member Function Documentation

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
unsigned long long ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::area ( ) const
inline

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

{
unsigned long long total = 0;
for ( unsigned int y = 0; y < Y; ++y )
for ( unsigned int x = 0; x < X; ++x )
{
unsigned int size = nbLabels( x, y );
total += sizeof( MyLabelledMap );
if ( size > (N+1) )
total += ( 1 + ( size - N - 1 ) / M ) * ( M * sizeof( Value ) + 8 );
}
return total;
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::display ( ostream &  out,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

{
std::cerr << _data[ x ][ y ] << endl;
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
unsigned int ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::erase ( unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

{
return _data[ x ][ y ].erase( l );
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::getLabels ( std::vector< unsigned int > &  labels,
unsigned int  x,
unsigned int  y 
) const
inline

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

{
_data[ x ][ y ].labels().getLabels( labels );
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
bool ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::hasLabel ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

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

{
return _data[ x ][ y ].count( l );
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
unsigned int ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::nbLabels ( unsigned int  x,
unsigned int  y 
) const
inline

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

{
return _data[ x ][ y ].size();
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::setValue ( const Value &  val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

{
_data[ x ][ y ][ l ] = val;
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::setValueNoNewLabel ( const Value &  val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

{
_data[ x ][ y ].fastAt( l ) = val;
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
const Value& ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::value ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

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

{
return _data[ x ][ y ].fastAt( l );
}

Field Documentation

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
MyLabelledMap ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::_data[X][Y]
private

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


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