Struct sark_grids::sparse_grid::SparseGrid [−][src]
pub struct SparseGrid<T: Clone> { /* fields omitted */ }
Expand description
A sparse grid that stores elements in a BTreeMap.
Implementations
An iterator over all elements in the grid.
Yields (&u32,&mut T)
where u32
is the 1d position of the element in the grid.
An iterator over just the values in the grid.
Yields &T
.
A mutable iterator over just the values in the grid.
Yields &mut T
.
A mutable iterator over all elements in the grid.
Yields (&u32,&mut T)
where u32
is the 1d position of the element in the grid.
A 2d iterator over all elements in the grid.
Yields (UVec2,&mut T)
where UVec2
is the 2d position of the element in the grid.
A mutable iterator over all elements in the grid.
Yields (UVec,&mut T)
where UVec2
is the 2d position of the element in the grid.
Insert into a row of the grid using an iterator.
Will insert up to the length of a row.
pub fn insert_row_at(
&mut self,
xy: [i32; 2],
row: impl IntoIterator<Item = T> + Iterator<Item = T>
)
pub fn insert_row_at(
&mut self,
xy: [i32; 2],
row: impl IntoIterator<Item = T> + Iterator<Item = T>
)
Insert into a row of the grid using an iterator.
Will insert up to the length of a row.
pub fn insert_column(
&mut self,
x: usize,
column: impl IntoIterator<Item = T> + Iterator<Item = T>
)
pub fn insert_column(
&mut self,
x: usize,
column: impl IntoIterator<Item = T> + Iterator<Item = T>
)
Insert into a column of the grid using an iterator.
Will insert up to the height of a column.
pub fn insert_column_at(
&mut self,
xy: [i32; 2],
column: impl IntoIterator<Item = T> + Iterator<Item = T>
)
pub fn insert_column_at(
&mut self,
xy: [i32; 2],
column: impl IntoIterator<Item = T> + Iterator<Item = T>
)
Insert into a column of the grid using an iterator.
Will insert up to the height of a column.
Remove the element/tile at the given position.
Returns the removed element if one was present.
Remove the element/tile at the given 1d index.
Returns the removed element if one was present.
Converts a 2d grid position to it’s corresponding 1D index.
Converts a 2d grid position to it’s corresponding 1D index.
Converts a 1d index to it’s corresponding grid position.
Converts a 1d index to it’s corresponding grid position.
Returns the index of the bottom row (0
).
Returns the index of the left-most column (0
).
Returns the index of the right-most column.
Get the position of a tile on the grid at the given pivot.
Note that for even-sized grids the “center” will be rounded down.
For example, for a a 4x4 grid calling pivot_position(Pivot::Center)
will return (1,1)
.
Insert a value in the grid.
Returns None
if no value was already present. Otherwise the old value
is returned.
Retrieve a value in the grid from it’s 1d index.
Returns None
if there is no value at the index.
Retrieve a mutable value in the grid from it’s 1d index.
Returns None
if there is no value at the index.
Retrieve a value in the grid from it’s 2d position.
Returns None
if there is no value at the position.