diff options
| author | mat <git@matdoes.dev> | 2026-01-05 03:26:20 +0400 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-05 03:26:20 +0400 |
| commit | ec43a57d0bf51030a4bed668b8cca9e5d288b244 (patch) | |
| tree | 45be3dd211b78c9c9c4b9e9b53c83e0ffd779d06 /azalea/src/pathfinder | |
| parent | 23e982f8f28e5fb816e803e66b3a3ed1aa6d0506 (diff) | |
| download | azalea-drasl-ec43a57d0bf51030a4bed668b8cca9e5d288b244.tar.xz | |
slightly abstract binaryheap in pathfinder
Diffstat (limited to 'azalea/src/pathfinder')
| -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 { |
