6.60 ABA_RING< Type > Class Template Reference

template ABA_RING implements a bounded circular list with the property that if the list is full and an element is inserted the oldest element of the ring is removed

#include <ring.h>

Inheritance diagram for ABA_RING< Type >::


PIC


Public Member Functions

Private Attributes

Friends

6.60.1 Detailed Description

template<class Type> class ABA_RING< Type >

template ABA_RING implements a bounded circular list with the property that if the list is full and an element is inserted the oldest element of the ring is removed

Definition at line 49 of file ring.h.

6.60.2 Constructor & Destructor Documentation

6.60.2.1 template<class Type> ABA_RING< Type >::ABA_RING (ABA_GLOBAL * glob, int size)

The constructor.

Parameters:

glob
A pointer to the corresponding global object.
size
The length of the ring.

6.60.2.2 template<class Type> virtual ABA_RING< Type >::~ABA_RING () [virtual]

The destructor.

6.60.3 Member Function Documentation

6.60.3.1 ]

template<class Type> Type& ABA_RING< Type >::operator[ ] (int i)

Returns:

The i-th element of the ring. The operation is undefined if no element has been inserted in the i-th position so far.

Parameters:

i
The element being accessed.

6.60.3.2 ]

template<class Type> const Type& ABA_RING< Type >::operator[ ] (int i) const

The operator [] is overloaded for constant use.

6.60.3.3 template<class Type> void ABA_RING< Type >::insert (Type elem)

Inserts a new element into the ring.

If the ring is already full, this operation overwrites the oldest element in the ring.

Parameters:

elem
The element being inserted.

6.60.3.4 template<class Type> void ABA_RING< Type >::clear ()

Empties the ring.

6.60.3.5 template<class Type> int ABA_RING< Type >::size () const

Returns:

The size of the ring.

6.60.3.6 template<class Type> int ABA_RING< Type >::number () const

Returns:

The current number of elements in the ring.

6.60.3.7 template<class Type> Type ABA_RING< Type >::oldest () const

Returns:

The oldest element in the ring.

The result is undefined, if the ring is empty.

6.60.3.8 template<class Type> int ABA_RING< Type >::oldestIndex () const

Returns:

The index of the oldest element in the ring.

The result is undefined, if the ring is empty.

6.60.3.9 template<class Type> Type ABA_RING< Type >::newest () const

Returns:

The newest element in the ring.

The result is undefined if the ring is empty.

6.60.3.10 template<class Type> int ABA_RING< Type >::newestIndex () const

Returns:

The index of the newest element in the ring.

The result is undefined if the ring is empty.

6.60.3.11 template<class Type> int ABA_RING< Type >::previous (int i, Type & p) const

Can be used to access any element between the oldest and newest inserted element.

Returns:

0 If there are enough elements in the ring such that the element i entries before the newest one could be accessed,

1 otherwise.

Parameters:

i
The element i elements before the newest element is retrieved. If i is 0, then the function retrieves the newest element.
p
Contains the i-th element before the newest one in a successful call.

6.60.3.12 template<class Type> bool ABA_RING< Type >::empty () const

Returns:

true If no element is contained in the ring,

false otherwise.

6.60.3.13 template<class Type> bool ABA_RING< Type >::filled () const

Returns:

true If the ABA_RING is completely filled up,

false otherwise.

6.60.3.14 template<class Type> void ABA_RING< Type >::realloc (int newSize)

Changes the length of the ring.

Parameters:

newSize
The new length of the ring. If the ring decreases below the current number of elements in the ring, then the newSize newest elements stay in the ring.

6.60.4 Friends And Related Function Documentation

6.60.4.1 template<class Type> ostream& operator<< (ostream & out, const ABA_RING< Type > & ring) [friend]

The output operator writes the elements of the ring to an output stream starting with the oldest element in the ring.

Returns:

A reference to the output stream.

Parameters:

out
The output stream.
rhs
The ring being output.

6.60.5 Member Data Documentation

6.60.5.1 template<class Type> ABA_GLOBAL*ABA_RING< Type >::glob_ [private]

A pointer to the corresponding global object.

Definition at line 177 of file ring.h.

6.60.5.2 template<class Type> ABA_ARRAY<Type> ABA_RING< Type >::ring_ [private]

{An array storing the elements of the ring.

Definition at line 181 of file ring.h.

6.60.5.3 template<class Type> int ABA_RING< Type >::head_ [private]

The position in the array ring_ where the next element will be inserted.

Definition at line 185 of file ring.h.

6.60.5.4 template<class Type> bool ABA_RING< Type >::filled_ [private]

This member becomes true if ring is completely filled up.

Definition at line 189 of file ring.h.

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