DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock Struct Reference

#include <DGtal/base/LabelledMap.h>

Public Member Functions

 __AnyBlock ()
 
Datainsert (size_t idx, size_t size, const Data &v)
 
__AnyBlockerase (size_t idx, size_t size)
 

Data Fields

Data datas [M]
 
__AnyBlocknext
 

Detailed Description

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
struct DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock

Represents a block (except the first) in the container. Internal structure.

Definition at line 302 of file LabelledMap.h.

Constructor & Destructor Documentation

◆ __AnyBlock()

template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::__AnyBlock ( )
inline

Member Function Documentation

◆ erase()

template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
__AnyBlock * DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::erase ( size_t idx,
size_t size )
inline

Definition at line 357 of file LabelledMap.h.

358 {
359 // std::cerr << "__AnyBlock::erase(" << idx << "," << size << ")"
360 // << " this=" << this
361 // << " next=" << next
362 // << std::endl;
363 if ( size == 1 )
364 {
365 ASSERT( idx == 0 );
366 delete this;
367 return 0;
368 }
369 if ( idx < M )
370 {
371 std::copy( datas + idx + 1, datas + M, datas + idx );
372 if ( next != 0 )
373 {
374 ASSERT( size > M );
375 datas[ M - 1 ] = next->datas[ 0 ];
376 next = next->erase( 0, size - M );
377 }
378 }
379 else
380 next = next->erase( idx - M, size - M );
381 return this;
382 }
__AnyBlock * erase(size_t idx, size_t size)

References DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::datas, DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::erase(), and DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::next.

Referenced by DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::erase().

◆ insert()

template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
Data & DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::insert ( size_t idx,
size_t size,
const Data & v )
inline

Definition at line 306 of file LabelledMap.h.

307 {
308 ASSERT( idx <= size );
309 if ( idx >= M )
310 {
311 if ( next == 0 )
312 {
313 ASSERT( size == M );
314 ASSERT( idx == M );
315 next = new __AnyBlock;
316 return ( next->datas[ 0 ] = v );
317 }
318 else
319 {
320 ASSERT( size > M );
321 return next->insert( idx - M, size - M, v );
322 }
323 }
324 else
325 { // idx < M
326 if ( size <= ( M - 1) ) // ( size < ( M - 1) )
327 {
328 ASSERT( next == 0 );
329 std::copy_backward( datas + idx, datas + size,
330 datas + size + 1 );
331 return ( datas[ idx ] = v );
332 }
333 else
334 {
335 Data v1 = datas[ M - 1 ];
336 std::copy_backward( datas + idx, datas + M - 1, datas + M );
337 // if ( size >= M )
338 // {
339 if ( next == 0 )
340 {
341 ASSERT( size == M );
342 next = new __AnyBlock;
343 next->datas[ 0 ] = v1;
344 }
345 else
346 {
347 ASSERT( size > M );
348 next->insert( 0, size - M, v1 );
349 }
350 // }
351 return ( datas[ idx ] = v );
352 }
353 }
354 }
Data & insert(size_t idx, size_t size, const Data &v)

References DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::__AnyBlock(), DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::datas, DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::insert(), and DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::next.

Referenced by DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::insert().

Field Documentation

◆ datas

template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
Data DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::datas[M]

◆ next

template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
__AnyBlock* DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::next

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