Bounded circular lists.
More...
#include <ogdf/lib/abacus/ring.h>
|
| AbaRing (int size) |
| The constructor. More...
|
|
virtual | ~AbaRing () |
| The destructor. More...
|
|
void | clear () |
| Empties the ring. More...
|
|
bool | empty () const |
| Returns true if no element is contained in the ring, false otherwise. More...
|
|
bool | filled () const |
| Returns true If the ring is completely filled up, false otherwise. More...
|
|
void | insert (Type elem) |
| Inserts a new element into the ring. More...
|
|
Type | newest () const |
| Returns the newest element in the ring. More...
|
|
int | newestIndex () const |
| Returns the index of the newest element in the ring. More...
|
|
int | number () const |
| Returns the current number of elements in the ring. More...
|
|
Type | oldest () const |
| Returns the oldest element in the ring. More...
|
|
int | oldestIndex () const |
| Returns the index of the oldest element in the ring. More...
|
|
Type & | operator[] (int i) |
| Returns the i-th element of the ring. More...
|
|
const Type & | operator[] (int i) const |
| The operator [] is overloaded for constant use. More...
|
|
int | previous (int i, Type &p) const |
| Can be used to access any element between the oldest and newest inserted element. More...
|
|
void | realloc (int newSize) |
| Changes the length of the ring. More...
|
|
int | size () const |
| Returns the size of the ring. More...
|
|
|
bool | filled_ |
| This member becomes true if ring is completely filled up. More...
|
|
int | head_ |
| The position in the array ring_ where the next element will be inserted. More...
|
|
Array< Type > | ring_ |
| An array storing the elements of the ring. More...
|
|
template<class Type>
class abacus::AbaRing< Type >
Bounded circular lists.
The template AbaRing 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. With this implementation single elements cannot be removed, but the whole AbaRing can be cleared.
Definition at line 38 of file ring.h.
◆ AbaRing()
The constructor.
- Parameters
-
size | The length of the ring. |
◆ ~AbaRing()
The destructor.
Definition at line 61 of file ring.h.
◆ clear()
◆ empty()
Returns true if no element is contained in the ring, false otherwise.
◆ filled()
Returns true If the ring is completely filled up, false otherwise.
◆ insert()
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. |
◆ newest()
Returns the newest element in the ring.
The result is undefined if the ring is empty.
◆ newestIndex()
Returns the index of the newest element in the ring.
The result is undefined if the ring is empty.
◆ number()
Returns the current number of elements in the ring.
◆ oldest()
Returns the oldest element in the ring.
The result is undefined, if the ring is empty.
◆ oldestIndex()
Returns the index of the oldest element in the ring.
The result is undefined, if the ring is empty.
◆ operator[]() [1/2]
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. |
◆ operator[]() [2/2]
The operator [] is overloaded for constant use.
◆ previous()
Can be used to access any element between the oldest and newest inserted element.
- 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. |
- 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.
◆ realloc()
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. |
◆ size()
Returns the size of the ring.
◆ operator<<
template<class Type >
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const AbaRing< Type > & |
ring |
|
) |
| |
|
friend |
The output operator.
Writes the elements of the ring to an output stream starting with the oldest element in the ring.
- Parameters
-
out | The output stream. |
ring | The ring being output. |
- Returns
- A reference to the output stream.
◆ filled_
This member becomes true if ring is completely filled up.
Definition at line 164 of file ring.h.
◆ head_
The position in the array ring_ where the next element will be inserted.
Definition at line 161 of file ring.h.
◆ ring_
An array storing the elements of the ring.
Definition at line 158 of file ring.h.
The documentation for this class was generated from the following file:
- include/ogdf/lib/abacus/ring.h