FreeNOS
Public Member Functions | Private Attributes
Array< T, N > Class Template Reference

This is a wrapper class for a fixed size array. More...

#include <Array.h>

Inheritance diagram for Array< T, N >:
Sequence< T > Container Comparable< Sequence< T > >

Public Member Functions

 Array ()
 Default constructor. More...
 
 Array (const Array< T, N > &a)
 Copy constructor. More...
 
virtual bool insert (Size position, const T &item)
 Puts the given item at the given position. More...
 
virtual const T * get (Size position) const
 Returns the item at the given position. More...
 
virtual const T & at (Size position) const
 Returns a reference to the item at the given position. More...
 
virtual const T value (Size position) const
 Return value at the given position. More...
 
virtual Size size () const
 Returns the maximum size of this Array. More...
 
virtual Size count () const
 Returns the number of items in the Array. More...
 
- Public Member Functions inherited from Sequence< T >
virtual int insert (const T &item)
 Adds the given item to the Sequence, if possible. More...
 
virtual void fill (T value)
 Fill the Sequence with the given value. More...
 
virtual int remove (T value)
 Remove all items with the given value. More...
 
virtual bool removeAt (Size position)
 Removes the item at the given position. More...
 
virtual void clear ()
 Removes all items from the Sequence. More...
 
virtual bool contains (const T value) const
 Check if the given item is stored in this Sequence. More...
 
virtual int compareTo (const Sequence< T > &s) const
 Compare this Sequence to another Sequence. More...
 
virtual bool equals (const Sequence< T > &s) const
 Test if this Sequence is equal to an other Sequence. More...
 
const T & operator[] (int i) const
 Returns the item at the given position in the Sequence. More...
 
const T & operator[] (Size i) const
 Returns the item at the given position in the Sequence. More...
 
T & operator[] (int i)
 Returns the item at the given position in the Sequence. More...
 
T & operator[] (Size i)
 Returns the item at the given position in the Sequence. More...
 
- Public Member Functions inherited from Container
 Container ()
 Constructor. More...
 
virtual ~Container ()
 Destructor. More...
 
virtual bool isEmpty () const
 Check if the Container is empty. More...
 
virtual bool reserve (Size size)
 Ensure that at least the given size is available. More...
 
virtual bool shrink (Size size)
 Shrink the container size by the given amount of items. More...
 
virtual Size squeeze ()
 Try to minimize the memory required in the Container. More...
 
virtual bool resize (Size size)
 Change the size of the Container. More...
 
- Public Member Functions inherited from Comparable< Sequence< T > >
virtual ~Comparable ()
 Class destructor. More...
 

Private Attributes

m_array [N]
 The actual array where the data is stored. More...
 

Detailed Description

template<class T, Size N>
class Array< T, N >

This is a wrapper class for a fixed size array.

This class contains some extra functionality, somewhat like the Arrays class in Java.

Definition at line 39 of file Array.h.

Constructor & Destructor Documentation

◆ Array() [1/2]

template<class T , Size N>
Array< T, N >::Array ( )
inline

Default constructor.

Definition at line 46 of file Array.h.

◆ Array() [2/2]

template<class T , Size N>
Array< T, N >::Array ( const Array< T, N > &  a)
inline

Copy constructor.

Parameters
aArray reference to copy from.

Definition at line 55 of file Array.h.

Member Function Documentation

◆ at()

template<class T , Size N>
virtual const T& Array< T, N >::at ( Size  position) const
inlinevirtual

Returns a reference to the item at the given position.

Note that this function does not perform bounds checking. Position must be a valid index.

Parameters
positionValid index inside this array.
Returns
Reference to the item at the given position

Implements Sequence< T >.

Definition at line 110 of file Array.h.

◆ count()

template<class T , Size N>
virtual Size Array< T, N >::count ( ) const
inlinevirtual

Returns the number of items in the Array.

Returns
The same as size().

Implements Container.

Definition at line 148 of file Array.h.

◆ get()

template<class T , Size N>
virtual const T* Array< T, N >::get ( Size  position) const
inlinevirtual

Returns the item at the given position.

Parameters
positionThe position of the item to get.
Returns
Pointer to the item at the given position.

Implements Sequence< T >.

Definition at line 91 of file Array.h.

◆ insert()

template<class T , Size N>
virtual bool Array< T, N >::insert ( Size  position,
const T &  item 
)
inlinevirtual

Puts the given item at the given position.

If an item exists at the given position, it will be replaced by the given item.

Parameters
positionThe position to insert the item.
itemThe item to put
Returns
bool Whether putting the item at the given position succeeded.

Reimplemented from Sequence< T >.

Definition at line 74 of file Array.h.

Referenced by MpiProxy::processTerminate(), MpiProxy::startLocalProcess(), and MpiProxy::startRemoteProcess().

◆ size()

template<class T , Size N>
virtual Size Array< T, N >::size ( ) const
inlinevirtual

Returns the maximum size of this Array.

Returns
size The maximum size of this Array.

Implements Container.

Definition at line 138 of file Array.h.

Referenced by MpiProxy::processTerminate().

◆ value()

template<class T , Size N>
virtual const T Array< T, N >::value ( Size  position) const
inlinevirtual

Return value at the given position.

If position is not within bounds of this array, this function will return a default constructed T.

Parameters
positionIndex inside this array.
Returns
T at the given position or default constructed T.

Definition at line 125 of file Array.h.

Field Documentation

◆ m_array

template<class T , Size N>
T Array< T, N >::m_array[N]
private

The documentation for this class was generated from the following file: