Simplify ring buffer pushes
This commit is contained in:
parent
e219b2b5f9
commit
50d722a691
2 changed files with 12 additions and 7 deletions
|
@ -22,6 +22,10 @@ impl<T> RingBuffer<T> {
|
|||
RingBuffer { data: VecDeque::new(), offset: 0 }
|
||||
}
|
||||
|
||||
pub fn push(&mut self, value: T) {
|
||||
self.data.push_back(value);
|
||||
}
|
||||
|
||||
pub fn advance_right(&mut self)
|
||||
where
|
||||
T: Default,
|
||||
|
@ -34,6 +38,10 @@ impl<T> RingBuffer<T> {
|
|||
self.offset += 1;
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.data.clear();
|
||||
}
|
||||
|
||||
pub fn truncate(&mut self, len: usize) {
|
||||
self.data.truncate(len);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue