Crate array_deque

Source
Expand description

A fixed-capacity circular buffer (ring buffer) implementation.

This crate provides ArrayDeque, a double-ended queue with a fixed capacity that uses a circular buffer for efficient operations at both ends. Unlike std::collections::VecDeque, this implementation has a compile-time fixed capacity and will overwrite old elements when full.

§Examples

use array_deque::ArrayDeque;

let mut deque = ArrayDeque::new(3);
deque.push_back(1);
deque.push_back(2);
deque.push_back(3);

assert_eq!(deque.pop_front(), Some(1));
assert_eq!(deque.pop_back(), Some(3));

§Features

  • serde: Enable serialization and deserialization support with serde.

Structs§

ArrayDeque
A fixed-capacity double-ended queue implemented as a circular buffer.
ArrayDequeIntoIter
An iterator that moves elements out of an ArrayDeque.
ArrayDequeIter
An iterator over references to the elements of an ArrayDeque.