queue
Types
Queue
Functions
length
fn(queue: Queue<'a>) -> Int
new
∀ 't22 . fn () -> Queue<'a>
Creates a new empty queue.
test.assert_eq(queue.length(queue.new()), 0);pop_back
fn(queue: Queue<'a>) -> (Queue<'a>, Option<'a>)
pop_front
fn(queue: Queue<'a>) -> (Option<'a>, Queue<'a>)
Removes and returns the element at the front of the queue.
import core/option { None }
let (value, _) = queue.pop_front(queue.new());
test.assert_eq(value, None);push_back
fn(queue: Queue<'a>, value: 'a) -> Queue<'a>
Adds an element to the back of the queue.
import core/option { Some }
let q = queue.new()
|> queue.push_back(1)
|> queue.push_back(2)
|> queue.push_back(3);
let (a, q) = queue.pop_front(q);
let (b, q) = queue.pop_front(q);
let (c, _) = queue.pop_front(q);
test.assert_eq(a, Some(1));
test.assert_eq(b, Some(2));
test.assert_eq(c, Some(3));push_front
fn(queue: Queue<'a>, value: 'a) -> Queue<'a>
Adds an element to the front of the queue.
let q = queue.new()
|> queue.push_front(1)
|> queue.push_front(2)
|> queue.push_front(3);
test.assert_eq(queue.length(q), 3);