Which library to choose?
Do you have any experience with these libraries?
https://crates.io/crates/circular-queue
https://crates.io/crates/ringbuf
https://crates.io/crates/ringbuffer
https://crates.io/crates/ring_queue
Which library to choose?
Do you have any experience with these libraries?
https://crates.io/crates/circular-queue
https://crates.io/crates/ringbuf
https://crates.io/crates/ringbuffer
https://crates.io/crates/ring_queue
There is also std::collections::VecDeque
.
EDIT: Also dasp_ring_buffer - Rust. I would use the one from the standard library until you have a reason not to. If performance is an issue, leave it until you have your application, then benchmark different possibilities.
How to set "wrapping" for VecDeque
?
VecDeque
is "growable" rather than fixed size. When you do the 4th push_back, the implementation will allocate a new larger buffer (with capacity > 3), copy the existing data to it, and set the length to 3, before appending the new element and incrementing the length.
I need a constant size. And the oldest value to be overwritten.
What are the exact semantics you are looking for?
You can do this:
Careful - VecDeque will always round its capacity up to the nearest 2n − 1. For example:
use std::collections::VecDeque;
let v: VecDeque<u8> = VecDeque::with_capacity(10);
assert_eq!(v.capacity(), 15);
If you want to use arbitrary capacities, you'll need to store the capacity separately.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.