-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid_neighbor_iterator.h
42 lines (37 loc) · 1.12 KB
/
grid_neighbor_iterator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Licensed under the MIT License.
#include <stdbool.h>
#include "coordinate.h"
#include "directions.h"
#include "grid_graph.h"
/** Iterates over the neighbors of a vertex in a grid graph. */
struct GridNeighborIterator
{
struct GridGraph* grid;
struct Coordinate u;
struct Coordinate v;
enum Directions step;
enum Directions steps;
bool end;
};
/** Iterates over the neighbors of a vertex in a grid-based graph. */
typedef struct GridNeighborIterator* GridNeighborIterator;
/**
* Provides an iterator over the neighbors of a vertex in a grid-based graph.
*
* @param iterator when this method returns, contains the iterator. This
* argument is passed uninitialized.
* @param instance the `GridGraph` instance.
* @param source the source vertex.
* @param step a bitwise combination of allowed directions.
*/
void grid_neighbor_begin(
GridNeighborIterator iterator,
GridGraph instance,
Coordinate source,
Directions step);
/**
* Advances the iterator to the next neighboring vertex.
*
* @param iterator the iterator.
*/
void grid_neighbor_next(GridNeighborIterator iterator);