[−][src]Struct drumatech::structure::Stack
Fields
sp: usize
contents: Vec<T>
Methods
impl<T> Stack<T>
[src]
pub fn new(contents: Vec<T>) -> Stack<T>
[src]
the constructor is need tuple for initializing Stack
Examples
extern crate drumatech; use drumatech::structure; let mut stack = structure::Stack::new(vec![1,3,5,7,9]);
pub fn allocate(cap: usize) -> Stack<T>
[src]
the constructor is need capacity for allocating memories for Stack\ndon't forget to annotate type
Examples
extern crate drumatech; use drumatech::structure; let mut stack : structure::Stack<u8> = structure::Stack::allocate(100); //
pub fn push(&mut self, element: T)
[src]
push the value on the top of stack.
Examples
extern crate drumatech; use drumatech::structure; let mut stack : structure::Stack<u8> = structure::Stack::allocate(100); // stack.push(3); assert_eq!(stack.contents[0],3);
pub fn pop(&mut self) -> Option<T>
[src]
pop the value by the top of stack.
Examples
extern crate drumatech; use drumatech::structure; let mut stack : structure::Stack<u8> = structure::Stack::allocate(100); // stack.push(3); assert_eq!(stack.pop().unwrap(),3);
pub fn top(&self) -> Option<&T>
[src]
get the value by the top of stack without changing contents.
Examples
extern crate drumatech; use drumatech::structure; let mut stack : structure::Stack<u8> = structure::Stack::allocate(100); // stack.push(3); assert_eq!(*stack.top().unwrap(),3); assert_eq!(stack.pop().unwrap(),3);
impl<T: Clone> Stack<T>
[src]
pub fn base(&self) -> T
[src]
get the value by the base of stack without changing contents.
Examples
extern crate drumatech; use drumatech::structure; let mut stack : structure::Stack<u8> = structure::Stack::allocate(100); // stack.push(3); stack.push(2); assert_eq!(stack.base(),3); assert_eq!(stack.pop().unwrap(),2);
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,