#include <ring.h>
Inheritance diagram for ABA_RING< Type >:
Public Member Functions | |
ABA_RING (ABA_GLOBAL *glob, int size) | |
virtual | ~ABA_RING () |
The destructor. | |
Type & | operator[] (int i) |
const Type & | operator[] (int i) const |
The operator [] is overloaded for constant use. | |
void | insert (Type elem) |
void | clear () |
int | size () const |
int | number () const |
Type | oldest () const |
int | oldestIndex () const |
Type | newest () const |
int | newestIndex () const |
int | previous (int i, Type &p) const |
bool | empty () const |
bool | filled () const |
void | realloc (int newSize) |
Private Attributes | |
ABA_GLOBAL * | glob_ |
ABA_ARRAY< Type > | ring_ |
int | head_ |
bool | filled_ |
Friends | |
ostream & | operator<< (ostream &out, const ABA_RING< Type > &ring) |
The output operator writes the elements of the ring to an output stream starting with the oldest element in the ring. |
Definition at line 49 of file ring.h.
ABA_RING< Type >::ABA_RING | ( | ABA_GLOBAL * | glob, | |
int | size | |||
) |
The constructor.
glob | A pointer to the corresponding global object. | |
size | The length of the ring. |
Type& ABA_RING< Type >::operator[] | ( | int | i | ) |
i | The element being accessed. |
const Type& ABA_RING< Type >::operator[] | ( | int | i | ) | const |
The operator [] is overloaded for constant use.
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.
elem | The element being inserted. |
void ABA_RING< Type >::clear | ( | ) |
Empties the ring.
int ABA_RING< Type >::size | ( | ) | const |
int ABA_RING< Type >::number | ( | ) | const |
Type ABA_RING< Type >::oldest | ( | ) | const |
The result is undefined, if the ring is empty.
int ABA_RING< Type >::oldestIndex | ( | ) | const |
The result is undefined, if the ring is empty.
Type ABA_RING< Type >::newest | ( | ) | const |
The result is undefined if the ring is empty.
int ABA_RING< Type >::newestIndex | ( | ) | const |
The result is undefined if the ring is empty.
int ABA_RING< Type >::previous | ( | int | i, | |
Type & | p | |||
) | const |
Can be used to access any element between the oldest and newest inserted element.
1 otherwise.
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. |
bool ABA_RING< Type >::empty | ( | ) | const |
false otherwise.
bool ABA_RING< Type >::filled | ( | ) | const |
false otherwise.
void ABA_RING< Type >::realloc | ( | int | newSize | ) |
Changes the length of the ring.
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. |
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.
out | The output stream. | |
rhs | The ring being output. |
ABA_GLOBAL* ABA_RING< Type >::glob_ [private] |