Struct pathfinding::grid::Grid[][src]

pub struct Grid {
    pub width: usize,
    pub height: usize,
    // some fields omitted
}

Representation of a rectangular grid in which vertices can be added or removed. Edges are automatically created between adjacent vertices. By default, only vertical and horizontal edges are created, unless diagonal mode is enabled.

Internally, a Grid is represented either as a collection of vertices or as a collection of absent vertices, depending on the density of the grid. The switch between both representations is done automatically when vertices are added or removed, or when the grid is resized.

Fields

The grid width.

The grid height.

Methods

impl Grid
[src]

Create a new empty grid object of the given dimensions, with diagonal mode disabled.

Check if a (possibly removed) vertex belongs to the grid or if it is located outside the grid.

Enable diagonal mode. Diagonal edges will be created between adjacent vertices.

Disable diagonal mode. Only horizontal and vertical edges will be created between adjacent vertices.

Resize the grid to the given dimensions. Return true if this caused any existing vertex to be discarded.

Return the number of positions in this grid.

Return the number of vertices.

Add a new vertex. Return true if the vertex did not previously exist and has been added.

Remove a vertex. Return true if the vertex did previously exist and has been removed.

Add the borders of the grid. Return the number of added vertices.

Remove the borders of the grid. Return the number of removed vertices.

Remove all vertices from the grid. Return true if the grid previously contained at least one vertex.

Fill the grid with all possible vertices. Return true if this caused the addition of at least one vertex.

Return true if the grid contains no vertices.

Return true if no additional vertices can be set (because they are all already set).

Remove every existing vertex, and add all absent vertices. If you see the grid as a black and white array, imagine that the color are exchanged.

Check if a vertex is present.

Check if an edge is present.

Important traits for EdgesIterator<'a>

Iterate over edges.

Return the list of neighbours of a given vertex. If vertex is absent from the grid, an empty list is returned. Only existing vertices will be returned.

Important traits for GridIterator<'a>

Iterate over vertices.

Trait Implementations

impl Clone for Grid
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl FromIterator<(usize, usize)> for Grid
[src]

Creates a value from an iterator. Read more

impl IntoIterator for Grid
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<'a> IntoIterator for &'a Grid
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

impl Send for Grid

impl Sync for Grid