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 Types | Private Attributes
DynArrayXYOfLabelledMap< Value, L, TWord, N, M > Class Template Reference
Collaboration diagram for DynArrayXYOfLabelledMap< Value, L, TWord, N, M >:
Collaboration graph
[legend]

Public Types

typedef Value ValueType

Public Member Functions

 DynArrayXYOfLabelledMap (unsigned int _X, unsigned int _Y)
 ~DynArrayXYOfLabelledMap ()
size_t offset (unsigned int x, unsigned int y) const
void clear ()
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

Data Fields

const unsigned int X
const unsigned int Y

Private Types

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

Private Attributes

MyLabelledMap_data

Detailed Description

template<typename Value, unsigned int L, typename TWord, unsigned int N, unsigned int M>
class DynArrayXYOfLabelledMap< Value, L, 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 481 of file testMultiMap-benchmark.cpp.


Member Typedef Documentation

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

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

template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
typedef Value DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::ValueType

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


Constructor & Destructor Documentation

template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::DynArrayXYOfLabelledMap ( unsigned int  _X,
unsigned int  _Y 
)
inline

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

: X( _X ), Y( _Y )
{
_data = new MyLabelledMap[ X * Y ];
}
template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::~DynArrayXYOfLabelledMap ( )
inline

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

{
delete[] _data;
}

Member Function Documentation

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

Definition at line 565 of file testMultiMap-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, typename TWord , unsigned int N, unsigned int M>
void DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::clear ( )
inline

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

References DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::clear().

Referenced by DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::clear().

{
for ( unsigned int y = 0; y < Y; ++y )
for ( unsigned int x = 0; x < X; ++x )
_data[ offset( x, y ) ].clear();
}
template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
void DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::display ( ostream &  out,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

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

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

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

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

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

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

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

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

{
return _data[ offset( x, y ) ].size();
}
template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
size_t DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::offset ( unsigned int  x,
unsigned int  y 
) const
inline

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

{
return x * Y + y;
}
template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
void DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::setValue ( const Value &  val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

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

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

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

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

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

Field Documentation

template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
MyLabelledMap* DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::_data
private

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

template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
const unsigned int DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::X

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

template<typename Value , unsigned int L, typename TWord , unsigned int N, unsigned int M>
const unsigned int DynArrayXYOfLabelledMap< Value, L, TWord, N, M >::Y

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


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