Struct sark_grids::grid::Grid

source ·
pub struct Grid<T> { /* private fields */ }
Expand description

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

Implementations§

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

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.

How many tiles/elements are in the grid.

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

Try to retrieve the value at the given position.

Returns None if the position is out of bounds.

Gets the index for a given side.

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.

Iterates from left to right.

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)

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.

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

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.

Retrieve a linear slice of the underlying grid data.

Retrieve a mutable linear slice of the underlying grid data.

Returns the bounds of the grid.

Converts a 2d grid position to it’s corresponding 1D index. If a pivot was applied to the given grid point, it will be accounted for.

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

Convert a point from grid space (bottom-left origin) to world space (center origin).

Convert a point from world space (center origin) to grid space (bottom-left origin).

Retrieve a grid position from a pivoted point.

If no pivot has been applied, the point will be returned directly.

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
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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.