pub struct DijkstraMap {
pub map: Vec<f32>,
/* private fields */
}
Expand description
Representation of a Dijkstra flow map. map is a vector of floats, having a size equal to size_x * size_y (one per tile). size_x and size_y are stored for overflow avoidance. max_depth is the maximum number of iterations this search shall support.
Fields§
§map: Vec<f32>
Implementations§
Source§impl DijkstraMap
impl DijkstraMap
Sourcepub fn new<T>(
size_x: T,
size_y: T,
starts: &[usize],
map: &dyn BaseMap,
max_depth: f32,
) -> DijkstraMap
pub fn new<T>( size_x: T, size_y: T, starts: &[usize], map: &dyn BaseMap, max_depth: f32, ) -> DijkstraMap
Construct a new Dijkstra map, ready to run. You must specify the map size, and link to an implementation of a BaseMap trait that can generate exits lists. It then builds the map, giving you a result.
Sourcepub fn new_weighted<T>(
size_x: T,
size_y: T,
starts: &[(usize, f32)],
map: &dyn BaseMap,
max_depth: f32,
) -> DijkstraMap
pub fn new_weighted<T>( size_x: T, size_y: T, starts: &[(usize, f32)], map: &dyn BaseMap, max_depth: f32, ) -> DijkstraMap
Construct a new Dijkstra map, ready to run. You must specify the map size, and link to an implementation of a BaseMap trait that can generate exits lists. It then builds the map, giving you a result. Starts is provided as a set of tuples, two per tile. The first is the tile index, the second the starting weight (defaults to 0.0 on new)
Sourcepub fn new_empty<T>(size_x: T, size_y: T, max_depth: f32) -> DijkstraMap
pub fn new_empty<T>(size_x: T, size_y: T, max_depth: f32) -> DijkstraMap
Creates an empty Dijkstra map node.
pub fn clear(dm: &mut DijkstraMap)
Sourcepub fn build(dm: &mut DijkstraMap, starts: &[usize], map: &dyn BaseMap)
pub fn build(dm: &mut DijkstraMap, starts: &[usize], map: &dyn BaseMap)
Builds the Dijkstra map: iterate from each starting point, to each exit provided by BaseMap’s exits implementation. Each step adds cost to the current depth, and is discarded if the new depth is further than the current depth. WARNING: Will give incorrect results when used with non-uniform exit costs. Much slower algorithm required to support that. Automatically branches to a parallel version if you provide more than 4 starting points
Sourcepub fn build_weighted(
dm: &mut DijkstraMap,
starts: &[(usize, f32)],
map: &dyn BaseMap,
)
pub fn build_weighted( dm: &mut DijkstraMap, starts: &[(usize, f32)], map: &dyn BaseMap, )
Builds the Dijkstra map: iterate from each starting point, to each exit provided by BaseMap’s exits implementation. Each step adds cost to the current depth, and is discarded if the new depth is further than the current depth. WARNING: Will give incorrect results when used with non-uniform exit costs. Much slower algorithm required to support that. Automatically branches to a parallel version if you provide more than 4 starting points