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

Public Member Functions

 ArrayXYOfMap ()
void clear ()
const Value & value (unsigned int l, unsigned int x, unsigned int y)
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 Types

typedef std::map< unsigned int,
Value > 
MyMap
typedef MyMap::const_iterator ConstIterator

Private Attributes

MyMap _data [X][Y]

Detailed Description

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

Array[X][Y] of map<L,Value> Intermediate approach. Slower (between 30% and 40%) than ArrayXYOfLabelledMap and takes 50% to 100% twice as much place.

Note that 4000*4000*16 takes 861Mb. Note that 2000*2000*64 takes 218Mb.

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


Member Typedef Documentation

template<typename Value , unsigned int L, unsigned int X, unsigned int Y>
typedef MyMap::const_iterator ArrayXYOfMap< Value, L, X, Y >::ConstIterator
private

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

template<typename Value , unsigned int L, unsigned int X, unsigned int Y>
typedef std::map<unsigned int, Value> ArrayXYOfMap< Value, L, X, Y >::MyMap
private

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


Constructor & Destructor Documentation

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

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

{
}

Member Function Documentation

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

Definition at line 228 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 += ( size + 1 ) *
( sizeof( Value ) // one value per node
+ 3 * sizeof( Value* ) // three pointers
+ 2 //_RbTreeColor { _S_red = false, _S_black = true };
+ 8 // dynamic allocation );
);
}
return total;
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y>
void ArrayXYOfMap< Value, L, X, Y >::clear ( )
inline

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

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

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

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

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

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

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

{
labels.clear();
for ( ConstIterator it = _data[ x ][ y ].begin(), it_end = _data[ x ][ y ].end();
it != it_end; ++it )
labels.push_back( (*it).first );
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y>
bool ArrayXYOfMap< Value, L, X, Y >::hasLabel ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

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

{
return _data[ x ][ y ].count( l ) != 0;
}
template<typename Value , unsigned int L, unsigned int X, unsigned int Y>
unsigned int ArrayXYOfMap< Value, L, X, Y >::nbLabels ( unsigned int  x,
unsigned int  y 
) const
inline

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

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

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

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

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

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

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

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

Field Documentation

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

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


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