Puma Reference Manual Puma: Puma::Array< Item > Class Template Reference



Puma::Array< Item > Class Template Reference

Variable length array implementation. More...

#include <Puma/Array.h>

Inherited by Puma::Stack< Item > [private].

List of all members.

Public Member Functions

 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.
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.
template<>
void reset ()

Static Protected Attributes

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

Detailed Description

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

Variable length array implementation.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
is The default size of the array.
incr The default increment value.
template<class Item>
Puma::Array< Item >::Array ( const Array< Item > &  array  )  [inline]

Copy-constructor.

Parameters:
array The array to copy.
template<class Item >
Puma::Array< Item >::~Array (  )  [inline]

Destructor.

Destroys the array.


Member Function Documentation

template<class Item>
void Puma::Array< Item >::append ( const Item &  item  )  [inline]

Append an item to the array.

Parameters:
item The item to append.
template<class Item >
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:
index The array index.
template<class Item >
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:
index The array index.
template<class Item>
void Puma::Array< Item >::insert ( long  index,
const Item &  item 
) [inline]

Insert an item at the given array index.

Parameters:
index The array index.
item The item to insert.
template<class Item >
long Puma::Array< Item >::length (  )  const [inline]
template<class Item >
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:
index The array index.
template<class Item>
Array< Item > & Puma::Array< Item >::operator= ( const Array< Item > &  copy  )  [inline]

Assignment operator.

Parameters:
copy The array to copy.
template<class Item >
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:
index The array index.
template<class Item>
void Puma::Array< Item >::prepend ( const Item &  item  )  [inline]

Prepend an item.

Parameters:
item The item to prepend.
template<class Item >
void Puma::Array< Item >::remove ( long  index  )  [inline]

Remove the array item at the given array index.

Parameters:
index The array index.
template<>
void Puma::Array< int >::reset (  )  [inline]

Reimplemented in Puma::Stack< Item >.

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

Member Data Documentation

template<class Item>
const long Puma::Array< Item >::default_increment = 5 [static, protected]

Default array size increment.

template<class Item>
const long Puma::Array< Item >::default_init_size = 5 [static, protected]

Default array size.




Puma Reference Manual. Created on 24 Nov 2009.