Module collections/deque
collections/deque
Double-ended queue (ring buffer) with O(1) push/pop at both ends.
Example
{ Deque } :: import "std/collections/deque";
d := Deque(i32).new();
d.push_back(1);
d.push_front(0);
x := d.pop_front().unwrap(); // 0
Types
Deque
type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yoe46fb501_id_17) : Type)
Circular buffer supporting efficient push/pop at both front and back.
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(forall(T : Type), Deque(T), ...)
new : (fn() -> Self)Returns: Self
len : (fn(self: Self) -> usize)Returns: usize
is_empty : (fn(self: Self) -> bool)Returns: bool
_grow : (fn(self: Self, min_cap: usize) -> unit)Returns: unit
push_back : (fn(self: Self, val: T) -> unit)Returns: unit
push_front : (fn(self: Self, val: T) -> unit)Returns: unit
pop_front : (fn(self: Self) -> ?T)Returns: ?T
pop_back : (fn(self: Self) -> ?T)Returns: ?T
get : (fn(self: Self, index: usize) -> ?T)Returns: ?T
impl(forall(T : Type), Deque(T), Dispose(...))
dispose : (fn(self: Self) -> unit)Returns: unit
impl(forall(T : Type), Deque(T), ...)
into_iter : (fn(self : Self) -> DequeIter(T))Returns: DequeIter(T)
impl(forall(T : Type), Deque(T), ...)
iter : (fn(self : *(Self)) -> DequeIterPtr(T))Returns: DequeIterPtr(T)
impl(forall(T : Type), Deque(T), Index(usize)(...))
Output : Tindex : (fn(self: *(Self), idx: usize) -> *(Self.Output))Parameters
| Name | Type | Notes |
|---|---|---|
idx | usize |
Returns: *(Self.Output)
DequeIter
type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yoe46fb501_id_142) : Type)
Value iterator for Deque - yields elements by value (T) Traverses the circular buffer in logical order.
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(forall(T : Type), DequeIter(T), Iterator(...))
Item : Tnext : (fn(self : *(Self)) -> Option(T))Returns: Option(T)
DequeIterPtr
type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yoe46fb501_id_309) : Type)
Pointer iterator for Deque - yields pointers to elements (*(T)) Yields pointers into the circular buffer. Pointers are valid as long as the deque is not modified during iteration.
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(forall(T : Type), DequeIterPtr(T), Iterator(...))
Item : *(T)next : (fn(self : *(Self)) -> Option(*(T)))Returns: Option(*(T))