PUMA Library Reference Manual
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. More...
 
 Array (const Array< Item * > &array)
 Copy-constructor. More...
 
 ~Array ()
 Destructor. More...
 
Array< Item * > & operator= (const Array< Item * > &array)
 Assignment operator. More...
 
void append (const Item *item)
 Append an item to the array. More...
 
void insert (long idx, const Item *item)
 Insert an item at the given array index. More...
 
void prepend (const Item *item)
 Prepend an item. More...
 
void remove (long idx)
 Remove the array item at the given array index. More...
 
void reset ()
 Reset the array. More...
 
Item *& get (long idx)
 Get a reference to the array item at the given array index. More...
 
Item *& operator[] (long idx)
 Get a reference to the array item at the given array index. More...
 
Item * fetch (long idx) const
 Get the array item at the given array index. More...
 
Item *& lookup (long idx) 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...
 

Constructor & Destructor Documentation

◆ Array() [1/2]

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/2]

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

Copy-constructor.

Parameters
arrayThe array to copy.

◆ ~Array()

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

Destructor.

Destroys the array.

Member Function Documentation

◆ append()

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

Append an item to the array.

Parameters
itemThe item to append.

◆ fetch()

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.

◆ get()

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.

◆ insert()

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.

◆ length()

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

Get the number of items in the array.

Returns
Length of the array.

◆ lookup()

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.

◆ operator=()

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

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.

◆ prepend()

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

Prepend an item.

Parameters
itemThe item to prepend.

◆ remove()

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

Remove the array item at the given array index.

Parameters
idxThe array index.

◆ reset()

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

Reset the array.

Destroys the current array.