pub struct Queue<T: Clone> { /* fields omitted */ }
Expand description
a struct representing a queue which is a specific type of stack.
You push to the top and pop from the bottom.
create a new instance of a Queue
a new empty instance of a Queue
pub fn push(&mut self, val: T)
push a new element to the Queue
use stacking::stacks::Queue;
let mut queue: Queue<i32> = Queue::new();
queue.push(4);
queue.push(5);
assert_eq!(queue.pop(), Some(4));
assert_eq!(queue.pop(), Some(5));
pop the element at the bottom and return it’s value
the value of the element at the bottom
use stacking::stacks::Queue;
let mut queue: Queue<i32> = Queue::new();
queue.push(4);
queue.push(5);
assert_eq!(queue.pop(), Some(4));
assert_eq!(queue.pop(), Some(5));
get the length of the current Queue
the length of the current Queue as a usize
use stacking::stacks::Queue;
let mut queue: Queue<i32> = Queue::new();
assert_eq!(queue.len(), 0);
queue.push(4);
assert_eq!(queue.len(), 1);
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.