auto_cellular/common.rs
1/// Screen position of a physical space
2pub type ScreenPosition = (isize, isize);
3/// Index of a cell in a world
4pub type Index = (usize, usize);
5
6/// Dimensions of a world
7#[derive(Clone, Copy)]
8pub struct Dimensions(pub usize, pub usize);
9/// A grid
10pub type DoubleVec<T> = Vec<Vec<T>>;
11
12pub fn linearize<T>(vector: DoubleVec<T>) -> Vec<(Index, T)> {
13 vector
14 .into_iter()
15 .enumerate()
16 .flat_map(|(j, row)| {
17 row.into_iter()
18 .enumerate()
19 .map(move |(i, cell)| ((i, j), cell))
20 })
21 .collect()
22}