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 More...

#include <ring.h>

Inheritance diagram for ABA_RING< Type >:

ABA_ABACUSROOT List of all members.

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_GLOBALglob_
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.

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.


Constructor & Destructor Documentation

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.

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

The destructor.


Member Function Documentation

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.

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

The operator [] is overloaded for constant use.

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.

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

Empties the ring.

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

Returns:
The size of the ring.

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

Returns:
The current number of elements in the ring.

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.

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.

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.

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.

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.

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

Returns:
true If no element is contained in the ring,

false otherwise.

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

Returns:
true If the ABA_RING is completely filled up,

false otherwise.

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.


Friends And Related Function Documentation

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.


Member Data Documentation

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.

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.

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.

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:
Generated on Tue Aug 14 18:09:58 2007 for ABACUS by  doxygen 1.5.1