use crate::system::{GriddedPosition, Storage};

pub struct VectorStorage {
    backing: Vec<bool>,
    grid_size: u32,
    dimension: u32,
}

impl VectorStorage {
    pub fn new(grid_size: u32, dimension: u32) -> VectorStorage {
        VectorStorage { grid_size, dimension, backing: vec![false; (grid_size as usize).pow(dimension) as usize] }
    }
}

impl<P: GriddedPosition> Storage<P> for VectorStorage {
    fn is_occupied(&self, position: &P) -> bool {
        let i = position.linear_index(self.grid_size);
        println!("{i}");
        return self.backing[i];
    }

    fn deposit(&mut self, position: &P) {
        self.backing[position.linear_index(self.grid_size)] = true;
    }
}
