pub struct SparseGrid<T: Clone> { /* 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 (&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.

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 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 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 top row.

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.

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

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

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.