S3FC project page | S3FC home page |
#include <s3_ring_buffer.h>
Collaboration diagram for s3_ring_buffer:
Public Methods | |
s3_ring_buffer (const unsigned int n_capacity) | |
Construct a ring buffer with the specified capacity. More... | |
s3_ring_buffer (const unsigned int n_capacity, const T &t) | |
Construct a ring buffer with the specified capacity. More... | |
s3_ring_buffer (const s3_ring_buffer &t) | |
Copy constructor makes a deep copy. More... | |
~s3_ring_buffer () | |
Free the buffer memory. More... | |
void | push_back (const T &element) |
Insert an element at the end of the buffer. More... | |
unsigned int | size () const |
Return the number of elements in the buffer. More... | |
unsigned int | get_capacity () const |
Return the capacity of the buffer. More... | |
bool | empty () const |
Return true if the buffer is empty. More... | |
bool | full () const |
Return true if the buffer is full. More... | |
T & | operator[] (const unsigned int index) const |
The operator return a reference to the element indexed by index . More... | |
T & | back (void) const throw ( s3_index_exception ) |
Returns a reference to the last (i.e. More... | |
s3_ring_buffer & | operator= (const s3_ring_buffer &t) |
The assignment operator makes a deep copy of the data. More... | |
bool | operator== (const s3_ring_buffer &t) |
The equality operator checks whether all elements in the buffer are equal. More... | |
Private Attributes | |
unsigned int | capacity |
The capacity (length) of the ring buffer. More... | |
unsigned int | num_of_elems |
The number of elements stored in the buffer. More... | |
T * | buffer |
The data buffer. More... | |
unsigned int | buffer_start |
Index to the start (oldest element) of the ring buffer. More... |
The ring buffer is a fixed length storage bin, that overwrites the first elements when the buffer has reached capacity.
Definition at line 44 of file s3_ring_buffer.h.
|
Construct a ring buffer with the specified capacity. This constructor will create an empty buffer.
Definition at line 68 of file s3_ring_buffer.h. References buffer, buffer_start, capacity, and num_of_elems. |
|
Construct a ring buffer with the specified capacity.
This constructor will create a buffer of size
Definition at line 83 of file s3_ring_buffer.h. References buffer, buffer_start, capacity, num_of_elems, and push_back. |
|
Copy constructor makes a deep copy.
Definition at line 98 of file s3_ring_buffer.h. References buffer, buffer_start, capacity, get_capacity, num_of_elems, and push_back. |
|
Free the buffer memory.
Definition at line 115 of file s3_ring_buffer.h. References buffer. |
|
Returns a reference to the last (i.e. the newest) element. If the ring buffer contains no elements, an s3_index_exception is thrown.
Definition at line 205 of file s3_ring_buffer.h. References buffer, buffer_start, capacity, empty, full, and num_of_elems. |
|
Return true if the buffer is empty.
Definition at line 161 of file s3_ring_buffer.h. References size. Referenced by back. |
|
Return true if the buffer is full.
Definition at line 170 of file s3_ring_buffer.h. |
|
Return the capacity of the buffer.
Definition at line 153 of file s3_ring_buffer.h. References capacity. Referenced by operator=, operator==, and s3_ring_buffer. |
|
The assignment operator makes a deep copy of the data.
Definition at line 228 of file s3_ring_buffer.h. References buffer, buffer_start, capacity, get_capacity, num_of_elems, push_back, and size. |
|
The equality operator checks whether all elements in the buffer are equal. This code should undergo further testing before being used in cruise missile operating systems, etc. Definition at line 254 of file s3_ring_buffer.h. References get_capacity, operator[], and size. |
|
The operator return a reference to the element indexed by The index is counted from the start of the buffer (i.e. the oldest element in the buffer).
Definition at line 183 of file s3_ring_buffer.h. References buffer, buffer_start, capacity, and size. Referenced by operator==. |
|
Insert an element at the end of the buffer. If the buffer is full, the first (i.e. the oldest) element is removed. Definition at line 128 of file s3_ring_buffer.h. References buffer, buffer_start, capacity, full, num_of_elems, and size. Referenced by operator=, and s3_ring_buffer. |
|
Return the number of elements in the buffer.
Definition at line 145 of file s3_ring_buffer.h. References num_of_elems. Referenced by empty, full, operator=, operator==, operator[], and push_back. |
|
The data buffer.
Definition at line 58 of file s3_ring_buffer.h. Referenced by back, operator=, operator[], push_back, s3_ring_buffer, and ~s3_ring_buffer. |
|
Index to the start (oldest element) of the ring buffer.
Definition at line 61 of file s3_ring_buffer.h. Referenced by back, operator=, operator[], push_back, and s3_ring_buffer. |
|
The capacity (length) of the ring buffer.
Definition at line 52 of file s3_ring_buffer.h. Referenced by back, full, get_capacity, operator=, operator[], push_back, and s3_ring_buffer. |
|
The number of elements stored in the buffer.
Definition at line 55 of file s3_ring_buffer.h. Referenced by back, operator=, push_back, s3_ring_buffer, and size. |
Send comments to: s3fc@stonethree.com |
|