DGtal 1.3.0
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
DGtal::IndexedListWithBlocks< TValue, N, M >::AnyBlock Struct Reference

#include <DGtal/base/IndexedListWithBlocks.h>

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 250 of file IndexedListWithBlocks.h.

Constructor & Destructor Documentation

◆ AnyBlock()

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

Member Function Documentation

◆ erase()

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 297 of file IndexedListWithBlocks.h.

298 {
299 // std::cerr << "AnyBlock::erase(" << idx << "," << size << ")"
300 // << " this=" << this
301 // << " next=" << next
302 // << std::endl;
303 if ( size == 1 )
304 {
305 ASSERT( idx == 0 );
306 delete this;
307 return 0;
308 }
309 if ( idx < M )
310 {
311 std::copy( values + idx + 1, values + M, values + idx );
312 if ( next != 0 )
313 {
314 ASSERT( size > M );
315 values[ M - 1 ] = next->values[ 0 ];
316 next = next->erase( 0, size - M );
317 }
318 }
319 else
320 next = next->erase( idx - M, size - M );
321 return this;
322 }
AnyBlock * erase(unsigned int idx, unsigned int size)

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

◆ insert()

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 254 of file IndexedListWithBlocks.h.

255 {
256 ASSERT( idx <= size );
257 if ( idx >= M )
258 {
259 if ( next == 0 )
260 {
261 ASSERT( idx == M );
262 next = new AnyBlock;
263 next->values[ 0 ] = v;
264 }
265 else
266 next->insert( idx - M, size - M, v );
267 }
268 else
269 { // idx < M
270 if ( size < ( M - 1) )
271 {
272 std::copy_backward( values + idx, values + size,
273 values + size + 1 );
274 values[ idx ] = v;
275 }
276 else
277 {
278 Value v1 = values[ M - 1 ];
279 std::copy_backward( values + idx, values + M - 1, values + M );
280 values[ idx ] = v;
281 if ( size >= M )
282 {
283 if ( next == 0 )
284 {
285 ASSERT( size == M );
286 next = new AnyBlock;
287 next->values[ 0 ] = v1;
288 }
289 else
290 next->insert( 0, size - M, v1 );
291 }
292 }
293 }
294 }
void insert(unsigned int idx, unsigned int size, const Value &v)

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

Field Documentation

◆ next

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

◆ values

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: