Uses old Rust 2015
|0.2.6||Jul 27, 2020|
|0.2.5||Jun 21, 2020|
|0.2.4||Mar 26, 2020|
|0.2.3||Jan 9, 2020|
|0.1.2||Jul 21, 2017|
#394 in Data structures
7,967 downloads per month
Used in 17 crates (12 directly)
A circular buffer-like queue container. Created with a set capacity. When pushing new items over capacity, old ones get overwritten. Supports iteration in newest to oldest and in oldest to newest order.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
A circular buffer-like queue.
CircularQueue<T> is created with a set capacity, then items are pushed in. When the queue
runs out of capacity, newer items start overwriting the old ones, starting from the oldest.
There are built-in iterators that go from the newest items to the oldest ones and from the oldest items to the newest ones.
Two queues are considered equal if iterating over them with
iter() would yield the same
sequence of elements.
serde_support feature for Serde support.
use circular_queue::CircularQueue; let mut queue = CircularQueue::with_capacity(3); queue.push(1); queue.push(2); queue.push(3); queue.push(4); assert_eq!(queue.len(), 3); let mut iter = queue.iter(); assert_eq!(iter.next(), Some(&4)); assert_eq!(iter.next(), Some(&3)); assert_eq!(iter.next(), Some(&2));