PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::Array< Item * > Class Template Reference

#include <Array.h>

+ Inheritance diagram for Puma::Array< Item * >:

Description

template<class Item>
class Puma::Array< Item * >

Variable length array implementation specialized for pointer types.

Grows with an increasing increment.

Template Parameters
ItemThe array item type. Needs to be a pointer type.

Public Member Functions

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

Static Protected Attributes

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

Constructor & Destructor Documentation

◆ Array() [1/4]

template<class Item>
Puma::Array< Item * >::Array ( long is = default_init_size,
long incr = default_increment )
inline

Constructor.

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

◆ Array() [2/4]

template<class Item>
Puma::Array< Item * >::Array ( const Array< Item * > & array)
inline

Copy-constructor.

Parameters
arrayThe array to copy.

◆ ~Array() [1/2]

template<class Item>
Puma::Array< Item * >::~Array ( )
inline

Destructor.

Destroys the array.

◆ Array() [3/4]

Puma::Array< Item >::Array ( long is = default_init_size,
long incr = default_increment )
inline

Constructor.

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

◆ Array() [4/4]

Puma::Array< Item >::Array ( const Array< Item > & array)
inline

Copy-constructor.

Parameters
arrayThe array to copy.

◆ ~Array() [2/2]

Puma::Array< Item >::~Array ( )
inline

Destructor.

Destroys the array.

Member Function Documentation

◆ append() [1/2]

void Puma::Array< Item >::append ( const Item & item)
inline

Append an item to the array.

Parameters
itemThe item to append.

◆ append() [2/2]

template<class Item>
void Puma::Array< Item * >::append ( const Item * item)
inline

Append an item to the array.

Parameters
itemThe item to append.

◆ fetch() [1/2]

template<class Item>
Item * Puma::Array< Item * >::fetch ( long idx) const
inline

Get the array item at the given array index.

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

◆ fetch() [2/2]

Item Puma::Array< Item >::fetch ( long index) const
inline

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() [1/2]

template<class Item>
Item *& Puma::Array< Item * >::get ( long idx)
inline

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
idxThe array index.
Returns
A reference to the n-th array item.

◆ get() [2/2]

Item & Puma::Array< Item >::get ( long index)
inline

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() [1/2]

template<class Item>
void Puma::Array< Item * >::insert ( long idx,
const Item * item )
inline

Insert an item at the given array index.

Parameters
idxThe array index.
itemThe item to insert.

◆ insert() [2/2]

void Puma::Array< Item >::insert ( long index,
const Item & item )
inline

Insert an item at the given array index.

Parameters
indexThe array index.
itemThe item to insert.

◆ length() [1/2]

long Puma::Array< Item >::length ( ) const
inline

Get the number of items in the array.

Returns
The length of the array.

◆ length() [2/2]

template<class Item>
long Puma::Array< Item * >::length ( ) const
inline

Get the number of items in the array.

Returns
Length of the array.

◆ lookup() [1/2]

template<class Item>
Item *& Puma::Array< Item * >::lookup ( long idx) const
inline

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

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

◆ lookup() [2/2]

Item & Puma::Array< Item >::lookup ( long index) const
inline

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=() [1/2]

template<class Item>
Array< Item * > & Puma::Array< Item * >::operator= ( const Array< Item * > & array)
inline

Assignment operator.

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

◆ operator=() [2/2]

Array< Item > & Puma::Array< Item >::operator= ( const Array< Item > & copy)
inline

Assignment operator.

Parameters
copyThe array to copy.

◆ operator[]() [1/2]

template<class Item>
Item *& Puma::Array< Item * >::operator[] ( long idx)
inline

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
idxThe array index.
Returns
A reference to the n-th array item.

◆ operator[]() [2/2]

Item & Puma::Array< Item >::operator[] ( long index)
inline

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() [1/2]

void Puma::Array< Item >::prepend ( const Item & item)
inline

Prepend an item.

Parameters
itemThe item to prepend.

◆ prepend() [2/2]

template<class Item>
void Puma::Array< Item * >::prepend ( const Item * item)
inline

Prepend an item.

Parameters
itemThe item to prepend.

◆ remove() [1/2]

template<class Item>
void Puma::Array< Item * >::remove ( long idx)
inline

Remove the array item at the given array index.

Parameters
idxThe array index.

◆ remove() [2/2]

void Puma::Array< Item >::remove ( long index)
inline

Remove the array item at the given array index.

Parameters
indexThe array index.

◆ reset() [1/4]

void Puma::Array< Item >::reset ( )
inline

Reset the array.

Destroys the current array.

◆ reset() [2/4]

void Puma::Array< int >::reset ( )
inline

◆ reset() [3/4]

void Puma::Array< int >::reset ( )
inline

◆ reset() [4/4]

template<class Item>
void Puma::Array< Item * >::reset ( )
inline

Reset the array.

Destroys the current array.

Member Data Documentation

◆ default_increment

const long Puma::Array< Item >::default_increment
staticprotected

Default array size increment.

◆ default_init_size

const long Puma::Array< Item >::default_init_size
staticprotected

Default array size.