diff --git a/src/main.rs b/src/main.rs index 12ab113..c7eb191 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ mod app; mod config; mod generate; mod request; +mod queue; const NUM_LEDS: usize = 150; diff --git a/src/queue.rs b/src/queue.rs new file mode 100644 index 0000000..a95d8c3 --- /dev/null +++ b/src/queue.rs @@ -0,0 +1,31 @@ +struct Queue { + pub queue: Vec +} + +impl Queue { + pub fn new() -> Self { + Queue { + queue: Vec::new() + } + } + + pub fn enqueue(&mut self, item: T) { + self.queue.push(item) + } + + pub fn dequeue(&mut self) -> T { + self.queue.remove(0) + } + + pub fn length(&self) -> usize { + self.queue.len() + } + + pub fn is_empty(&self) -> bool { + self.queue.is_empty() + } + + pub fn peek(&self) -> Option<&T> { + self.queue.first() + } +}