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
Fork of AEB by
CircularBuffer.cpp
- Committer:
- clynamen
- Date:
- 2016-07-31
- Revision:
- 5:d64e042b573d
- Parent:
- 2:5811e080f41d
File content as of revision 5:d64e042b573d:
#include "CircularBuffer.h"
#include <algorithm>
#include <math.h>
CircularBuffer::CircularBuffer(int size) : size(size) {
}
void CircularBuffer::push_back(float v) {
values.push_back(v);
}
bool isFirstGreater(float x, float y) {
return x > y;
}
float CircularBuffer::median() {
std::sort(values.begin(), values.end(), isFirstGreater);
return values[floor((float)values.size()/2)];
}
