ECE 4180 - Final Project Team / Mbed 2 deprecated WalkieTalkie

Dependencies:   mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P

Embed: (wiki syntax)

« Back to documentation index

CircularBuf< T > Class Template Reference

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:
sizeSize 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:
dataThe array of data popped
sizeThe 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:
DataThe array of data to add to the buffer
sizeThe 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.