WPILibC++
unspecified
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Pages
CircularBuffer.h
1
/*----------------------------------------------------------------------------*/
2
/* Copyright (c) FIRST 2015-2016. All Rights Reserved. */
3
/* Open Source Software - may be modified and shared by FRC teams. The code */
4
/* must be accompanied by the FIRST BSD license file in the root directory of */
5
/* the project. */
6
/*----------------------------------------------------------------------------*/
7
8
#pragma once
9
10
#include <vector>
11
#include <cstddef>
12
17
template
<
class
T>
18
class
CircularBuffer
{
19
public
:
20
CircularBuffer
(
size_t
size);
21
22
void
PushFront(T value);
23
void
PushBack(T value);
24
T PopFront();
25
T PopBack();
26
void
Reset();
27
28
T& operator[](
size_t
index);
29
const
T& operator[](
size_t
index)
const
;
30
31
private
:
32
std::vector<T> m_data;
33
34
// Index of element at front of buffer
35
size_t
m_front = 0;
36
37
// Number of elements used in buffer
38
size_t
m_length = 0;
39
40
size_t
ModuloInc(
size_t
index);
41
size_t
ModuloDec(
size_t
index);
42
};
43
44
#include "CircularBuffer.inc"
CircularBuffer
This is a simple circular buffer so we don't need to "bucket brigade" copy old values.
Definition:
CircularBuffer.h:18
shared
include
CircularBuffer.h
Generated on Thu Feb 11 2016 16:34:49 for WPILibC++ by
1.8.6