pub struct SparseGrid<T> { /* private fields */ }
Expand description

A sparse grid that stores elements in a BTreeMap.

Implementations§

Creates a new SparseGrid.

An iterator over all elements in the grid.

Yields (&usize,&mut T) where usize 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 (&usize,&mut T) where usize is the 1d position of the element in the grid.

A 2d iterator over all elements in the grid.

Yields (IVec2,&mut T) where IVec2 is the 2d position of the element in the grid.

A mutable iterator over all elements in the grid.

Yields (IVec,&mut T) where IVec2 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.

Insert into a row of the grid using an iterator.

Will insert up to the length of a row.

Insert into a column of the grid using an iterator.

Will insert up to the height of a column.

Insert into a column of the grid starting from some point 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.

Clears the grid, removing all elements.

How many tiles/elements are in the grid.

Converts a 2d grid position to it’s corresponding 1D index.

Converts a 1d index to it’s corresponding grid position.

Gets the index for a given side.

Returns true if the position is in the bounds of the grid. Note this doesn’t necessarily mean a tile exists at that point - just that it’s in bounds.

Returns the bounds of the grid.

Insert a value in the grid at the given 1d index.

Returns None if no value was already present. Otherwise the old value is returned.

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, or if the position is out of bounds.

Retrieve a mutable value in the grid from it’s 2d position.

Returns None if there is no value at the position.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.