Expand description
A fixed capacity double-ended queue.
§Examples
use heapless::Deque;
// A deque with a fixed capacity of 8 elements allocated on the stack
let mut deque = Deque::<_, 8>::new();
// You can use it as a good old FIFO queue.
deque.push_back(1);
deque.push_back(2);
assert_eq!(deque.len(), 2);
assert_eq!(deque.pop_front(), Some(1));
assert_eq!(deque.pop_front(), Some(2));
assert_eq!(deque.len(), 0);
// Deque is double-ended, you can push and pop from the front and back.
deque.push_back(1);
deque.push_front(2);
deque.push_back(3);
deque.push_front(4);
assert_eq!(deque.pop_front(), Some(4));
assert_eq!(deque.pop_front(), Some(2));
assert_eq!(deque.pop_front(), Some(1));
assert_eq!(deque.pop_front(), Some(3));
// You can iterate it, yielding all the elements front-to-back.
for x in &deque {
println!("{}", x);
}
Structs§
- Deque
Inner - Base struct for
Deque
andDequeView
, generic over theVecStorage
. - Into
Iter - An iterator that moves out of a
Deque
. - Iter
- Iterator over the contents of a
Deque
- IterMut
- Iterator over the contents of a
Deque