diff options
Diffstat (limited to 'azalea/src')
| -rw-r--r-- | azalea/src/pathfinder/astar.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs index 7bd08111..d5dc86bd 100644 --- a/azalea/src/pathfinder/astar.rs +++ b/azalea/src/pathfinder/astar.rs @@ -52,7 +52,7 @@ where { let start_time = Instant::now(); - let mut open_set = BinaryHeap::<WeightedNode>::new(); + let mut open_set = PathfinderHeap::new(); open_set.push(WeightedNode { g_score: 0., f_score: 0., @@ -282,6 +282,23 @@ impl<P: Hash + Copy + Clone, M: Clone> Clone for Movement<P, M> { } } +#[derive(Default)] +struct PathfinderHeap { + binary_heap: BinaryHeap<WeightedNode>, +} +impl PathfinderHeap { + pub fn new() -> Self { + Self::default() + } + + pub fn push(&mut self, item: WeightedNode) { + self.binary_heap.push(item); + } + pub fn pop(&mut self) -> Option<WeightedNode> { + self.binary_heap.pop() + } +} + #[derive(PartialEq)] #[repr(C)] pub struct WeightedNode { |
