PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::VoidPtrArray Class Reference

#include <Puma/VoidPtrArray.h>

+ Inheritance diagram for Puma::VoidPtrArray:

Description

Array implementation specialized for void pointers.

Protected Member Functions

 VoidPtrArray (long is=default_init_size, long incr=default_increment)
 Constructor. More...
 
 VoidPtrArray (const VoidPtrArray &array)
 Copy-constructor. More...
 
VoidPtrArrayoperator= (const VoidPtrArray &array)
 Assignment operator. More...
 
 ~VoidPtrArray ()
 Destructor. More...
 
void append (const void *item)
 Append an item to the array. More...
 
void insert (long index, const void *item)
 Insert an item at the given array index. More...
 
void prepend (const void *item)
 Prepend an item. More...
 
void remove (long index)
 Remove the array item at the given array index. More...
 
void reset ()
 Reset the array. More...
 
void *& get (long index)
 Get a reference to the array item at the given array index. More...
 
void *& operator[] (long index)
 Get a reference to the array item at the given array index. More...
 
void * fetch (long index) const
 Get the array item at the given array index. More...
 
void *& lookup (long index) const
 Get a reference to the array item at the given array index. More...
 
long length () const
 Get the number of items in the array. More...
 

Static Protected Attributes

static const long default_init_size
 Default array size. More...
 
static const long default_increment
 Default array size increment. More...
 

Constructor & Destructor Documentation

◆ VoidPtrArray() [1/2]

Puma::VoidPtrArray::VoidPtrArray ( long  is = default_init_size,
long  incr = default_increment 
)
inlineprotected

Constructor.

Parameters
isThe default size of the array.
incrThe default increment value.

◆ VoidPtrArray() [2/2]

Puma::VoidPtrArray::VoidPtrArray ( const VoidPtrArray array)
inlineprotected

Copy-constructor.

Parameters
arrayThe array to copy.

◆ ~VoidPtrArray()

Puma::VoidPtrArray::~VoidPtrArray ( )
inlineprotected

Destructor.

Destroys the array.

Member Function Documentation

◆ append()

void Puma::VoidPtrArray::append ( const void *  item)
inlineprotected

Append an item to the array.

Parameters
itemThe item to append.

◆ fetch()

void * Puma::VoidPtrArray::fetch ( long  index) const
inlineprotected

Get the array item at the given array index.

Does not return a reference, thus the item may be implicitely copied.

Warning
Does not validate the index!
Parameters
indexThe array index.
Returns
The n-th array item.

◆ get()

void *& Puma::VoidPtrArray::get ( long  index)
inlineprotected

Get a reference to the array item at the given array index.

If the index exceeds the array bounds, then the array is reallocated accordingly.

Parameters
indexThe array index.
Returns
A reference to the n-th array item.

◆ insert()

void Puma::VoidPtrArray::insert ( long  index,
const void *  item 
)
inlineprotected

Insert an item at the given array index.

Parameters
indexThe array index.
itemThe item to insert.

◆ length()

long Puma::VoidPtrArray::length ( ) const
inlineprotected

Get the number of items in the array.

Returns
The length of the array.

◆ lookup()

void *& Puma::VoidPtrArray::lookup ( long  index) const
inlineprotected

Get a reference to the array item at the given array index.

Warning
Does not validate the index!
Parameters
indexThe array index.
Returns
A reference to the n-th array item.

◆ operator=()

VoidPtrArray & Puma::VoidPtrArray::operator= ( const VoidPtrArray array)
inlineprotected

Assignment operator.

Parameters
arrayThe array to copy.
Returns
A reference to this array.

◆ operator[]()

void *& Puma::VoidPtrArray::operator[] ( long  index)
inlineprotected

Get a reference to the array item at the given array index.

If the index exceeds the array bounds, then the array is reallocated accordingly.

Parameters
indexThe array index.
Returns
A reference to the n-th array item.

◆ prepend()

void Puma::VoidPtrArray::prepend ( const void *  item)
inlineprotected

Prepend an item.

Parameters
itemThe item to prepend.

◆ remove()

void Puma::VoidPtrArray::remove ( long  index)
inlineprotected

Remove the array item at the given array index.

Parameters
indexThe array index.

◆ reset()

void Puma::VoidPtrArray::reset ( )
inlineprotected

Reset the array.

Destroys the current array.

Member Data Documentation

◆ default_increment

const long Puma::VoidPtrArray::default_increment
staticprotected

Default array size increment.

◆ default_init_size

const long Puma::VoidPtrArray::default_init_size
staticprotected

Default array size.