mirror of
https://github.com/lisk77/comet.git
synced 2025-10-23 21:38:50 +00:00
fix(ecs): added safety boundaries to the IdQueue
This commit is contained in:
parent
7cf9f5bd29
commit
88fda5c654
1 changed files with 32 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct IdQueue {
|
||||
queue: Vec<u32>
|
||||
queue: Vec<u32>,
|
||||
}
|
||||
|
||||
impl IdQueue {
|
||||
|
@ -13,7 +13,10 @@ impl IdQueue {
|
|||
}
|
||||
|
||||
pub fn front(&self) -> Option<u32> {
|
||||
Some(self.queue[0])
|
||||
if self.queue.len() > 0 {
|
||||
return Some(self.queue[0]);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn enqueue(&mut self, id: u32) {
|
||||
|
@ -26,8 +29,10 @@ impl IdQueue {
|
|||
}
|
||||
|
||||
pub fn dequeue(&mut self) -> Option<u32> {
|
||||
Some(self.queue.remove(0))
|
||||
|
||||
if self.queue.len() > 0 {
|
||||
return Some(self.queue.remove(0));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue