Fennel: CircularBuffer< T > Class Template Reference (original) (raw)
A circular buffer containing a maximum of N entries of type T. More...
#include <[CircularBuffer.h](CircularBuffer%5F8h-source.html)>
| Public Member Functions | |
|---|---|
| CircularBuffer () | |
| CircularBuffer (uint nEntriesInit) | |
| void | clear () |
| Initializes the buffer to an empty state. | |
| void | resize (uint nEntriesInit) |
| Resizes the number of entries in the circular buffer. | |
| uint | size () |
| **Returns:**max number of entries that can be stored in the buffer | |
| bool | empty () |
| **Returns:**true if the buffer is empty | |
| bool | spaceAvailable () |
| **Returns:**true if there is space available in the buffer | |
| uint | nFreeSpace () |
| **Returns:**number of free entries available in the buffer | |
| uint | getFirstPos () |
| **Returns:**the position of the first entry in the buffer | |
| uint | getLastPos () |
| **Returns:**the position of the last entry in the buffer | |
| T & | reference_back () |
| **Returns:**reference to the last entry in the buffer | |
| void | push_back (T &newEntry) |
| Adds an entry to the end of the buffer. | |
| T & | reference_front () |
| **Returns:**reference to the first entry in the buffer | |
| void | pop_front () |
| Removes the first entry from the buffer. | |
| T & | operator[] (uint pos) |
| Returns the entry at a specified position in the circular buffer. | |
| bool | isReadOnly () |
| **Returns:**true if the buffer is readonly | |
| void | setReadOnly () |
| Sets the buffer to a readonly state. | |
| Private Member Functions | |
| void | init (uint nEntriesInit) |
| Initializes the buffer. | |
| Private Attributes | |
| std::vector< T > | buffer |
| Vector used to represent the contents of the circular buffer. | |
| uint | nEntries |
| Number of entries in the buffer. | |
| uint | nFreeEntries |
| Number of free entries in the buffer. | |
| uint | firstPos |
| Position of the current, first entry in the circular buffer. | |
| bool | readOnly |
| If true, no additional new entries can be added to the buffer. |
Detailed Description
template
class CircularBuffer< T >
A circular buffer containing a maximum of N entries of type T.
The max size of the buffer must be set before the buffer can be used.
Definition at line 34 of file CircularBuffer.h.
Constructor & Destructor Documentation
Member Function Documentation
template
| bool CircularBuffer< T >::spaceAvailable | ( | | ) | [inline] | | -------------------------------------------------------------------- | - | | - | ---------- |
Returns:
the position of the first entry in the buffer
Definition at line 143 of file CircularBuffer.h.
template
| void CircularBuffer< T >::push_back | ( | T & | newEntry | ) | [inline] |
|---|
template
| T& CircularBuffer< T >::reference_front | ( | | ) | [inline] | | -------------------------------------------------------------------- | - | | - | ---------- |
Returns the entry at a specified position in the circular buffer.
Parameters:
Returns:
reference to the entry
Definition at line 205 of file CircularBuffer.h.
Member Data Documentation
Number of entries in the buffer.
Definition at line 44 of file CircularBuffer.h.
Referenced by CircularBuffer< std::pair< PageId, EntryT > >::clear(), CircularBuffer< std::pair< PageId, EntryT > >::empty(), CircularBuffer< std::pair< PageId, EntryT > >::getLastPos(), CircularBuffer< std::pair< PageId, EntryT > >::init(), CircularBuffer< std::pair< PageId, EntryT > >::operator, CircularBuffer< std::pair< PageId, EntryT > >::push_back(), CircularBuffer< std::pair< PageId, EntryT > >::reference_back(), CircularBuffer< std::pair< PageId, EntryT > >::reference_front(), and CircularBuffer< std::pair< PageId, EntryT > >::size().
Number of free entries in the buffer.
Definition at line 49 of file CircularBuffer.h.
Referenced by CircularBuffer< std::pair< PageId, EntryT > >::clear(), CircularBuffer< std::pair< PageId, EntryT > >::empty(), CircularBuffer< std::pair< PageId, EntryT > >::getLastPos(), CircularBuffer< std::pair< PageId, EntryT > >::nFreeSpace(), CircularBuffer< std::pair< PageId, EntryT > >::pop_front(), CircularBuffer< std::pair< PageId, EntryT > >::push_back(), and CircularBuffer< std::pair< PageId, EntryT > >::spaceAvailable().
Position of the current, first entry in the circular buffer.
Position always increases, even after positions in the circular buffer are recycled.
Definition at line 56 of file CircularBuffer.h.
Referenced by CircularBuffer< std::pair< PageId, EntryT > >::clear(), CircularBuffer< std::pair< PageId, EntryT > >::getFirstPos(), CircularBuffer< std::pair< PageId, EntryT > >::getLastPos(), CircularBuffer< std::pair< PageId, EntryT > >::pop_front(), CircularBuffer< std::pair< PageId, EntryT > >::push_back(), and CircularBuffer< std::pair< PageId, EntryT > >::reference_front().
The documentation for this class was generated from the following file:
- /home/pub/open/dev/fennel/common/CircularBuffer.h
