Module vecdeque

Source
Description

VecDeque — double-ended queue with O(1) push/pop at both ends.

VecDeque elem is a newtype over (Vec elem) — runtime layout matches Vec, but dispatch treats it as a nominally distinct type. .from-vec / .to-vec are identity casts at the cell level; the checker still rejects Vec-only methods on a VecDeque.

Most methods (.len, .is-empty, .front, .back, .push-back, .push-front, .pop-front, .pop-back, .reverse, .to-vec, vecdeque-from-vec) have real bodies backed by host intrinsics. Front-side ops run in O(n) under the current Vec-backed layout; the O(1) guarantee returns with a real ring-buffer runtime.

.rotate-left, .rotate-right, vecdeque-contains, and vecdeque-retain remain panicking stubs until Result-returning intrinsics, (Eq elem elem) constraint resolution inside intrinsics, and host-side quotation dispatch land. Seq-hierarchy impls arrive alongside the Bytes follow-ups.

Not re-exported by the prelude — use :use :open silo:std.collections.vecdeque ....

Data Types

Types

VecDeque

Double-ended queue.

Functions

Functions

vecdeque-contains

.contains — free-fn form, takes (Eq elem elem) by trait constraint.

vecdeque-from-vec

Convert a (Vec elem) to a (VecDeque elem), preserving element order.

vecdeque-retain

.retain — free-fn form, keeps elements for which the predicate is

Trait Implementations

impl VecDeque for ?570302

.back ( (VecDeque elem) (Option elem) )

.back returns Some with the back element or None if empty. O(1).

.front ( (VecDeque elem) (Option elem) )

.front returns Some with the front element or None if empty. O(1).

.is-empty ( (VecDeque elem) Bool )

True iff the deque contains zero elements.

.len ( (VecDeque elem) (Int ..) )

Number of elements in O(1).

.pop-back ( (VecDeque elem) (VecDeque elem) (Option elem) )

Remove and return the back element. O(1).

.pop-front ( (VecDeque elem) (VecDeque elem) (Option elem) )

Remove and return the front element. Spec-guaranteed O(1); O(n) on the Vec-layout stub. Returns the modified deque then the (Option elem)Some when non-empty, None otherwise.

.push-back ( elem (VecDeque elem) (VecDeque elem) )

Append an element to the back. Amortised O(1).

.push-front ( elem (VecDeque elem) (VecDeque elem) )

Prepend an element to the front. Spec-guaranteed O(1); on the Vec-layout stub this rebuilds the backing Vec so it is O(n) until the ring-buffer runtime lands.

.reverse ( (VecDeque elem) (VecDeque elem) )

Return a new VecDeque with elements in reverse order. O(n).

.rotate-left ( (Int ..) (VecDeque elem) (VecDeque elem) )

Rotate left by n positions; first n elements move to the back. n is taken modulo .len; negative n is a runtime error. Stub.

.rotate-right ( (Int ..) (VecDeque elem) (VecDeque elem) )

Rotate right by n positions; last n elements move to the front. n is taken modulo .len; negative n is a runtime error. Stub.

.to-vec ( (VecDeque elem) (Vec elem) )

Convert a (VecDeque elem) to a (Vec elem) in front-to-back order. Runtime identity cast — the underlying cell is already a Vec.