crow/col/mut-deque.crow
(source)
mut-deque
[t
] record
mut
(has non-public fields)
Mutable double-ended queue.
new
[t
] t
mut-deque
()
New empty mut-deque
.
to
[t
] t
array
(a
t
mut-deque
)
Copy elements to a list.
This is O(n).
copy
[t
] t
mut-deque
(a
t
mut-deque
)
Copy elements to a new deque.
is-empty
[t
] bool
(a
t
mut-deque
)
true
iff a.size == 0
.
size
[t
] nat64
(a
t
mut-deque
)
Number of elements in the deque.
push
[t
] void
(value
t
, a
t
mut-deque
)
Push a value to the left.
push
[t
] void
(a
t
mut-deque
, value
t
)
Push a value to the right.
peek-left
[t
] t
?
(a
t
mut-deque
)
Returns the leftmost element without removing it.
Returns an empty option iff a
is empty.
peek-right
[t
] t
?
(a
t
mut-deque
)
Returns the rightmost element without removing it.
Returns an empty option iff a
is empty.
pop-left
[t
] t
?
(a
t
mut-deque
)
Removes and returns the leftmost element.
Returns an empty option iff a
was empty (before calling pop-left
).
pop-right
[t
] t
?
(a
t
mut-deque
)
Removes and returns the rightmost element.
Returns an empty option iff a
was empty (before calling pop-right
).