pub struct Grid<T: Clone> { /* private fields */ }
Expand description

A dense sized grid that stores it’s elements in a Vec.

This grid assumes that [0,0] refers to the bottom-left most tile, and [width -1, height -1] refers to the top-right-most tile.

Implementations

Creates a new Grid with the given default value set for all elements.

Creates a new Grid with all elements initialized to default values.

An iterator over all elements in the grid.

A mutable iterator over all elements in the grid.

An iterator over a single row of the grid.

Goes from left to right.

A mutable iterator over a single row of the grid.

Goes from left to right.

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.

An iterator over a single column of the grid.

Goes from bottom to top.

A mutable iterator over a single column of the grid.

Goes from bottom to top.

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.

Get the position of the given pivot point on the grid.

Gets the index for a given side.

An iterator over a rectangular portion of the grid defined by the given range.

Yields (IVec2, &T), where IVec2 is the corresponding position of the value in the grid.

Returns an iterator which enumerates the 2d position of every value in the grid.

Yields (IVec2, &T), where IVec2 is the corresponding position of the value in the grid.

Returns a mutable iterator which enumerates the 2d position of every value in the grid.

Yields (IVec2, &mut T), where IVec2 is the corresponding position of the value in the grid.

Creates a crate::world_grid::WorldGrid from this grid with the given pivot. This can be used to translate between grid points and world space.

Creates a crate::world_grid::WorldGrid from this grid with the default bottom left pivot. This can be used to translate between grid points and world space.

Iterate over a range of rows.

Yields &[T] (Slice of T)

Iterate mutably over a range of rows.

Yields &mut [T] (Slice of mutable T)

Final index along a given axis, where 0 == width, and 1 == height.

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.