lol.rs
Lol
This commit is contained in:
commit
a026817b1f
1 changed files with 49 additions and 0 deletions
49
lol.rs
Normal file
49
lol.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// fuck notohhd donut imma impleme t sracks based on areayss
|
||||
// https://femboy.beauty/o6T3a
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct Stack<T> {
|
||||
size: usize,
|
||||
data: Box<[Option<T>]>,
|
||||
}
|
||||
|
||||
|
||||
impl<T: Copy> Stack<T> {
|
||||
pub const MAX_SIZE: usize = 100;
|
||||
|
||||
fn new() -> Stack<T> {
|
||||
Stack {
|
||||
size: 0,
|
||||
data: Box::new([None; Stack::<()>::MAX_SIZE]),
|
||||
}
|
||||
}
|
||||
|
||||
fn pop(&mut self) -> T {
|
||||
let r = self.data[self.size - 1].unwrap();
|
||||
self.size -= 1;
|
||||
r
|
||||
}
|
||||
|
||||
fn push(&mut self, e: T) {
|
||||
self.data[self.size] = Some(e);
|
||||
self.size += 1;
|
||||
}
|
||||
|
||||
fn first(&self) -> T {
|
||||
self.data[self.size - 1].unwrap()
|
||||
}
|
||||
|
||||
fn size(&self) -> usize {
|
||||
self.size
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.size == 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
println!(":)");
|
||||
|
||||
}
|
Loading…
Reference in a new issue