Struct stacking::stack::stacks::Queue[][src]

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.

Implementations

create a new instance of a Queue

Returns

a new empty instance of a Queue

push a new element to the Queue

Arguments

  • val: the value to push

Examples

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

Returns

the value of the element at the bottom

Examples

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

Returns

the length of the current Queue as a usize

Examples

use stacking::stacks::Queue;

let mut queue: Queue<i32> = Queue::new();
assert_eq!(queue.len(), 0);
queue.push(4);
assert_eq!(queue.len(), 1);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

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.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.