std.deque
ring-buffer deque in an arena; O(1) push/pop at both ends; grows 2x
pub Deque :: struct($T: type) { region: *Arena, data: []T, head: usize, count: usize,}region: where it grows (borrowed)data: the ring; capacity == data.lenhead: where the front element is
Deque.len
Section titled “Deque.len”pub len :: fn(self: *Self) -> usizeDeque.is_empty
Section titled “Deque.is_empty”pub is_empty :: fn(self: *Self) -> boolDeque.push_back
Section titled “Deque.push_back”pub push_back :: fn(self: *Self, item: T)Deque.push_front
Section titled “Deque.push_front”pub push_front :: fn(self: *Self, item: T)Deque.pop_front
Section titled “Deque.pop_front”pub pop_front :: fn(self: *Self) -> ?Ttake the front; null if empty
Deque.pop_back
Section titled “Deque.pop_back”pub pop_back :: fn(self: *Self) -> ?Ttake the back; null if empty
Deque.front
Section titled “Deque.front”pub front :: fn(self: *Self) -> ?TDeque.back
Section titled “Deque.back”pub back :: fn(self: *Self) -> ?TDeque.get
Section titled “Deque.get”pub get :: fn(self: *Self, i: usize) -> Telement i from the front; i < len()
Deque.set
Section titled “Deque.set”pub set :: fn(self: *Self, i: usize, v: T)Deque.each
Section titled “Deque.each”pub each :: fn(self: *Self) -> Each(T)front to back, left in place
Deque.clear
Section titled “Deque.clear”pub clear :: fn(self: *Self)pub Each :: struct($T: type) { d: *Deque(T), i: usize,}iterator from Deque.each
Each.next
Section titled “Each.next”pub next :: fn(self: *Self) -> ?Tpub make :: fn($T: type, a: *Arena) -> Deque(T)with_cap
Section titled “with_cap”pub with_cap :: fn($T: type, a: *Arena, cap: usize) -> Deque(T)deque in a with room for cap before it grows