31 #if defined(LabelledMap_RECURSES)
32 #error Recursive header files inclusion detected in LabelledMap.h
33 #else // defined(LabelledMap_RECURSES)
35 #define LabelledMap_RECURSES
37 #if !defined LabelledMap_h
46 #include "DGtal/base/Common.h"
47 #include "DGtal/base/Labels.h"
117 template <
typename TData,
unsigned int L,
typename TWord,
118 unsigned int N,
unsigned int M>
132 typedef std::pair<const Key, Data>
Value;
182 { data.nextBlock = 0; }
187 ASSERT( idx <= size );
191 return (
datas[ idx ] = v );
193 else if ( size == N )
197 data.lastData =
datas[ N - 1 ];
199 return (
datas[ idx ] = v );
203 return ( data.lastData = v );
206 else if ( size == (N+1) )
214 next->
datas[ 1 ] = data.lastData;
216 data.nextBlock = next;
217 return (
datas[ idx ] = v );
221 next->
datas[ 1 ] = data.lastData;
222 data.nextBlock = next;
223 return ( next->
datas[ 0 ] = v );
227 next->
datas[ 0 ] = data.lastData;
228 data.nextBlock = next;
229 return ( next->
datas[ 1 ] = v );
238 data.nextBlock->insert( 0, size - N, v1 );
239 return (
datas[ idx ] = v );
242 return data.nextBlock->insert( idx - N, size - N, v );
247 void erase(
unsigned int idx,
unsigned int size )
253 ASSERT( idx < size );
254 if ( size <= ( N + 1 ) )
260 else if ( size == N + 2 )
265 datas[ N - 1 ] = data.nextBlock->datas[ 0 ];
266 Data tmp = data.nextBlock->datas[ 1 ];
267 delete data.nextBlock;
272 Data tmp = data.nextBlock->datas[ 1 ];
273 delete data.nextBlock;
278 Data tmp = data.nextBlock->datas[ 0 ];
279 delete data.nextBlock;
288 datas[ N - 1 ] = data.nextBlock->datas[ 0 ];
289 data.nextBlock = data.nextBlock->erase( 0, size - N );
292 data.nextBlock = data.nextBlock->erase( idx - N, size - N );
308 ASSERT( idx <= size );
326 if ( size <= ( M - 1) )
329 std::copy_backward(
datas + idx,
datas + size,
331 return (
datas[ idx ] = v );
351 return (
datas[ idx ] = v );
746 return v1.first < v2.first;
774 template <
typename InputIterator>
775 LabelledMap( InputIterator first, InputIterator last );
905 std::pair<Iterator, bool>
insert(
const Value & val );
933 template <
typename InputIterator>
934 void insert( InputIterator first, InputIterator last );
963 ConstIterator
begin()
const;
966 ConstIterator
end()
const;
1018 std::pair<ConstIterator, ConstIterator>
equal_range(
const Key & x )
const;
1056 ConstIterator
find (
const Key & x )
const;
1205 BlockConstIterator
blockEnd()
const;
1255 template <
typename TData,
unsigned int L,
typename TWord,
1256 unsigned int N,
unsigned int M>
1275 unsigned int sL,
unsigned int sV,
1276 unsigned int sP,
unsigned int sA )
1281 double fctNM(
unsigned int N,
unsigned int M )
const
1283 double alpha0 =
_sL +
_sV * ( N+1 );
1286 + beta0 *
_q * pow(1.0 -
_p, (
double)N+1)
1287 * ( 1.0 + pow(1.0 -
_p, (
double)M-1 )
1288 / ( 1.0 - pow(1.0 -
_p, (
double)M ) ) );
1291 double fctNMpq(
unsigned int N,
unsigned int M,
double p,
double q )
const
1293 double alpha0 =
_sL +
_sV * ( N+1 );
1296 + beta0 * q * pow(1.0 - p, (
double)N+1)
1297 * ( 1.0 + pow(1.0 - p, (
double)M-1 )
1298 / ( 1.0 - pow(1.0 - p, (
double)M ) ) );
1322 template <
typename TData>
1323 std::pair< unsigned int, unsigned int >
1325 (
unsigned int L,
double prob_no_data,
double prob_one_data );
1333 #include "DGtal/base/LabelledMap.ih"
1338 #endif // !defined LabelledMap_h
1340 #undef LabelledMap_RECURSES
1341 #endif // else defined(LabelledMap_RECURSES)