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
Diff: CircularBuf.cpp
- Revision:
- 20:e068469ffb89
- Parent:
- 17:604f9c4bd6d3
- Child:
- 29:0c6f3c0c992a
--- a/CircularBuf.cpp Fri Apr 20 16:12:01 2018 +0000 +++ b/CircularBuf.cpp Fri Apr 20 18:39:20 2018 +0000 @@ -1,17 +1,17 @@ #include "CircularBuf.h" -template <class T> -CircularBuf::CircularBuf(unsigned int size) : _size(size) { +template <typename T> +CircularBuf<T>::CircularBuf(unsigned int size) : _size(size) { _data = new T[size]; } -template <class T> -CircularBuf::~CircularBuf() { +template <typename T> +CircularBuf<T>::~CircularBuf() { delete _data; } -template <class T> -unsigned int CircularBuf::push(T* data, unsigned int size) { +template <typename T> +unsigned int CircularBuf<T>::push(T* data, unsigned int size) { unsigned int cnt = 0; for (int i = 0; i < size; i++) { @@ -31,8 +31,8 @@ return cnt; } -template <class T> -unsigned int CircularBuf::pop(T* data, unsigned int size) { +template <typename T> +unsigned int CircularBuf<T>::pop(T* data, unsigned int size) { unsigned int cnt = 0; for (int i = 0; i < size; i++) { @@ -52,8 +52,8 @@ return cnt; } -template <class T> -unsigned int CircularBuf::size() { +template <typename T> +unsigned int CircularBuf<T>::size() { int s = _head - _tail; // If buffer overlaps end @@ -63,8 +63,8 @@ return s; } -template <class T> -void CircularBuf::clear() { +template <typename T> +void CircularBuf<T>::clear() { _head = 0; _tail = 0; } \ No newline at end of file