Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P
CircularBuf< T > Class Template Reference
Circular Buffer class. More...
#include <CircularBuf.h>
Public Member Functions | |
CircularBuf (unsigned int size) | |
Assigns a circular buffer of the given size. | |
unsigned int | push (T *data, unsigned int size) |
Pushes data onto the buffer. | |
unsigned int | pop (T *data, unsigned int size) |
Pops data from the buffer. |
Detailed Description
template<typename T>
class CircularBuf< T >
Circular Buffer class.
Definition at line 16 of file CircularBuf.h.
Constructor & Destructor Documentation
CircularBuf | ( | unsigned int | size ) |
Assigns a circular buffer of the given size.
- Parameters:
-
size Size of the buffer.
Definition at line 5 of file CircularBuf.cpp.
Member Function Documentation
unsigned int pop | ( | T * | data, |
unsigned int | size | ||
) |
Pops data from the buffer.
- Parameters:
-
data The array of data popped size The amount of data to pop Return: Amount of data actually popped
Example Code:
int dataToRemove[2]; buffer.pop(dataToRemove, 2);
dataToRemove now contains the 2 oldest values that were in buffer
Definition at line 36 of file CircularBuf.cpp.
unsigned int push | ( | T * | data, |
unsigned int | size | ||
) |
Pushes data onto the buffer.
Returns the amount of data actually written.
- Parameters:
-
Data The array of data to add to the buffer size The amount of data in the array.
(Adds data to the buffer) Argument:/n Data: The array of data to add to the buffer. data: The array of data to add size: The amount of data in the array Return: Amount of data actually written
Example Code:
int dataToAdd[2]; dataToAdd[0] = 15; dataToAdd[1] = 23; buffer.push(dataToAdd, 2);
buffer now contains [15, 23]
Definition at line 15 of file CircularBuf.cpp.
Generated on Tue Jul 12 2022 11:14:19 by
