DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Data Fields
DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock Struct Reference

#include <IndexedListWithBlocks.h>

Collaboration diagram for DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock:
Collaboration graph
[legend]

Public Member Functions

 AnyBlock ()
void insert (unsigned int idx, unsigned int size, const Value &v)
AnyBlockerase (unsigned int idx, unsigned int size)

Data Fields

Value values [M]
AnyBlocknext

Detailed Description

template<typename TValue, unsigned int N, unsigned int M>
struct DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock

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

Definition at line 251 of file IndexedListWithBlocks.h.


Constructor & Destructor Documentation

template<typename TValue, unsigned int N, unsigned int M>
DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::AnyBlock ( )
inline

Member Function Documentation

template<typename TValue, unsigned int N, unsigned int M>
AnyBlock* DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::erase ( unsigned int  idx,
unsigned int  size 
)
inline

Definition at line 298 of file IndexedListWithBlocks.h.

References DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::erase(), DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::next, and DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::values.

Referenced by DGtal::IndexedListWithBlocks< TValue, 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( values + idx + 1, values + M, values + idx );
if ( next != 0 )
{
ASSERT( size > M );
values[ M - 1 ] = next->values[ 0 ];
next = next->erase( 0, size - M );
}
}
else
next = next->erase( idx - M, size - M );
return this;
}
template<typename TValue, unsigned int N, unsigned int M>
void DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::insert ( unsigned int  idx,
unsigned int  size,
const Value v 
)
inline

Definition at line 255 of file IndexedListWithBlocks.h.

References DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::AnyBlock(), DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::insert(), DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::next, and DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::values.

Referenced by DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::insert().

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

Field Documentation

template<typename TValue, unsigned int N, unsigned int M>
AnyBlock* DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::next
template<typename TValue, unsigned int N, unsigned int M>
Value DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock::values[M]

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