Struct pathfinding::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]

[src]

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

[src]

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

[src]

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

[src]

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

[src]

Return the number of positions in this grid.

[src]

Return the number of vertices.

[src]

Add a new vertex. Return true if the vertex did not previously exist.

[src]

Remove a vertex. Return true if the vertex did previously exist.

[src]

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

[src]

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

[src]

Return true if the grid contains no vertices.

[src]

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

[src]

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.

[src]

Check if a vertex is present.

[src]

Check if an edge is present.

[src]

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.

[src]

Iterate over vertices.

Trait Implementations

impl Clone for Grid
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[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?

[src]

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?

[src]

Creates an iterator from a value. Read more