forEachNeighbour

fun forEachNeighbour(node: T, action: (T) -> Unit)

Executes a given function on all the neighbours of a given node.

More performant than retrieving a copied list of nodes and calling forEach on them. NOTE: For performance, the node is not validated. Passing a node that isn't in the graph results in undefined behaviour (e.g. Graph will add it as a new node, and Grid may process a different tile's neighbours).

Parameters

node

The node whose neighbours we want to process

action

The function to be called on each neighbour