DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Data Fields
DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock Struct Reference

#include <LabelledMap.h>

Collaboration diagram for DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock:
Collaboration graph
[legend]

Public Member Functions

 __AnyBlock ()
Datainsert (unsigned int idx, unsigned int size, const Data &v)
__AnyBlockerase (unsigned int idx, unsigned int 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

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

Definition at line 303 of file LabelledMap.h.

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

: next( 0 ) {}

Member Function Documentation

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

Definition at line 357 of file LabelledMap.h.

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().

{
// std::cerr << "__AnyBlock::erase(" << idx << "," << size << ")"
// << " this=" << this
// << " next=" << next
// << std::endl;
if ( size == 1 )
{
ASSERT( idx == 0 );
delete this;
return 0;
}
if ( idx < M )
{
std::copy( datas + idx + 1, datas + M, datas + idx );
if ( next != 0 )
{
ASSERT( size > M );
datas[ M - 1 ] = next->datas[ 0 ];
next = next->erase( 0, size - M );
}
}
else
next = next->erase( idx - M, size - M );
return this;
}
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Data& DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::insert ( unsigned int  idx,
unsigned int  size,
const Data v 
)
inline

Definition at line 306 of file LabelledMap.h.

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().

{
ASSERT( idx <= size );
if ( idx >= M )
{
if ( next == 0 )
{
ASSERT( size == M );
ASSERT( idx == M );
return ( next->datas[ 0 ] = v );
}
else
{
ASSERT( size > M );
return next->insert( idx - M, size - M, v );
}
}
else
{ // idx < M
if ( size <= ( M - 1) ) // ( size < ( M - 1) )
{
ASSERT( next == 0 );
std::copy_backward( datas + idx, datas + size,
datas + size + 1 );
return ( datas[ idx ] = v );
}
else
{
Data v1 = datas[ M - 1 ];
std::copy_backward( datas + idx, datas + M - 1, datas + M );
// if ( size >= M )
// {
if ( next == 0 )
{
ASSERT( size == M );
next->datas[ 0 ] = v1;
}
else
{
ASSERT( size > M );
next->insert( 0, size - M, v1 );
}
// }
return ( datas[ idx ] = v );
}
}
}

Field Documentation

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]
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: