DGtal 2.1.0
Loading...
Searching...
No Matches
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 Valuevalue (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 &, unsigned int, unsigned int, unsigned int)
 
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 76 of file testMultiMap-benchmark.cpp.

Member Typedef Documentation

◆ ValueType

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

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

Constructor & Destructor Documentation

◆ DynArrayLXY()

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

◆ ~DynArrayLXY()

template<typename Value >
DynArrayLXY< Value >::~DynArrayLXY ( )
inline

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

98 {
99 delete[] _data;
100 }

References DynArrayLXY< Value >::_data.

Member Function Documentation

◆ area()

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

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

170 {
171 return L * X * Y * sizeof( Value );
172 }

References DynArrayLXY< Value >::L, DynArrayLXY< Value >::X, and DynArrayLXY< Value >::Y.

◆ clear()

template<typename Value >
void DynArrayLXY< Value >::clear ( )
inline

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

103 {
104 for ( unsigned int l = 0; l < L; ++l )
105 for ( unsigned int x = 0; x < X; ++x )
106 for ( unsigned int y = 0; y < Y; ++y )
107 setValue( _invalid, l, x, y );
108 }
void setValue(const Value &val, unsigned int l, unsigned int x, unsigned int y)

References DynArrayLXY< Value >::_invalid, DynArrayLXY< Value >::L, DynArrayLXY< Value >::setValue(), DynArrayLXY< Value >::X, and DynArrayLXY< Value >::Y.

Referenced by DynArrayLXY< Value >::DynArrayLXY().

◆ display()

template<typename Value >
void DynArrayLXY< Value >::display ( ostream &  ,
unsigned int  ,
unsigned int  ,
unsigned int   
)
inline

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

166 {}

◆ erase()

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

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

122 {
123 size_t offs = offset( l, x, y );
124 if ( _data[ offs ] != _invalid )
125 {
126 _data[ offs ] = _invalid;
127 return 1;
128 }
129 return 0;
130 }
size_t offset(unsigned int l, unsigned int x, unsigned int y) const

References DynArrayLXY< Value >::_data, DynArrayLXY< Value >::_invalid, and DynArrayLXY< Value >::offset().

◆ getLabels()

template<typename Value >
void DynArrayLXY< Value >::getLabels ( std::vector< unsigned int > &  labels,
unsigned int  x,
unsigned int  y 
) const
inline

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

150 {
151 labels.clear();
152 for ( unsigned int l = 0; l < L; ++l )
153 if ( hasLabel( l, x, y ) )
154 labels.push_back( l );
155 }
bool hasLabel(unsigned int l, unsigned int x, unsigned int y) const

References DynArrayLXY< Value >::hasLabel(), and DynArrayLXY< Value >::L.

◆ hasLabel()

template<typename Value >
bool DynArrayLXY< Value >::hasLabel ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

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

144 {
145 return value( l, x, y ) != _invalid;
146 }
const Value & value(unsigned int l, unsigned int x, unsigned int y) const

References DynArrayLXY< Value >::_invalid, and DynArrayLXY< Value >::value().

Referenced by DynArrayLXY< Value >::getLabels(), and DynArrayLXY< Value >::nbLabels().

◆ nbLabels()

template<typename Value >
unsigned int DynArrayLXY< Value >::nbLabels ( unsigned int  x,
unsigned int  y 
) const
inline

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

158 {
159 unsigned int nb = 0;
160 for ( unsigned int l = 0; l < L; ++l )
161 if ( hasLabel( l, x, y ) ) ++nb;
162 return nb;
163 }

References DynArrayLXY< Value >::hasLabel(), and DynArrayLXY< Value >::L.

◆ offset()

template<typename Value >
size_t DynArrayLXY< Value >::offset ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

◆ setValue()

template<typename Value >
void DynArrayLXY< Value >::setValue ( const Value val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

134 {
135 _data[ offset( l, x, y ) ] = val;
136 }

References DynArrayLXY< Value >::_data, and DynArrayLXY< Value >::offset().

Referenced by DynArrayLXY< Value >::clear().

◆ setValueNoNewLabel()

template<typename Value >
void DynArrayLXY< Value >::setValueNoNewLabel ( const Value val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

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

139 {
140 _data[ offset( l, x, y ) ] = val;
141 }

References DynArrayLXY< Value >::_data, and DynArrayLXY< Value >::offset().

◆ value()

template<typename Value >
const Value & DynArrayLXY< Value >::value ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

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

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

References DynArrayLXY< Value >::_data, and DynArrayLXY< Value >::offset().

Referenced by DynArrayLXY< Value >::hasLabel().

Field Documentation

◆ _data

◆ _invalid

◆ L

◆ X

◆ Y


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