diff --git a/agb/src/arena.rs b/agb/src/arena.rs deleted file mode 100644 index 034ac3ff..00000000 --- a/agb/src/arena.rs +++ /dev/null @@ -1,100 +0,0 @@ -use alloc::vec::Vec; - -pub struct Arena { - first: Option, - data: Vec>, -} -enum Item { - Next { - next: Option, - generation: usize, - }, - Item { - item: T, - generation: usize, - }, -} - -#[derive(Debug, Clone, Copy)] -pub struct Index { - generation: usize, - index: usize, -} - -impl Arena { - #[must_use] - pub fn new() -> Self { - Arena { - first: None, - data: Vec::new(), - } - } - pub fn remove(&mut self, idx: Index) { - if let Item::Item { - item: _, - generation, - } = self.data[idx.index] - { - if generation != idx.generation { - return; - } - - self.data[idx.index] = Item::Next { - next: self.first, - generation, - }; - self.first = Some(idx.index); - } - } - pub fn get_mut(&mut self, idx: Index) -> Option<&mut T> { - match &mut self.data[idx.index] { - Item::Next { - next: _, - generation: _, - } => None, - Item::Item { item, generation } => { - if *generation == idx.generation { - Some(item) - } else { - None - } - } - } - } - pub fn insert(&mut self, data: T) -> Index { - match self.first { - Some(idx) => { - let (next, generation) = match &self.data[idx] { - Item::Next { next, generation } => (*next, *generation), - _ => unreachable!(), - }; - self.data[idx] = Item::Item { - item: data, - generation: generation + 1, - }; - - self.first = next; - Index { - generation: generation + 1, - index: idx, - } - } - None => { - self.data.push(Item::Item { - item: data, - generation: 0, - }); - Index { - generation: 0, - index: self.data.len() - 1, - } - } - } - } -} - -impl Default for Arena { - fn default() -> Self { - Self::new() - } -} diff --git a/agb/src/lib.rs b/agb/src/lib.rs index e80f0c70..764cdbfa 100644 --- a/agb/src/lib.rs +++ b/agb/src/lib.rs @@ -164,7 +164,6 @@ mod memory_mapped; pub mod mgba; #[doc(inline)] pub use agb_fixnum as fixnum; -pub mod arena; /// Contains an implementation of a hashmap which suits the gameboy advance's hardware. pub mod hash_map; /// Simple random number generator