Refactor into different crates

This commit is contained in:
hal8174 2025-01-18 17:30:55 +01:00
parent 94473c64e0
commit dfdeae5638
82 changed files with 624 additions and 647 deletions

View file

@ -0,0 +1,40 @@
use factorio_pathfinding::priority_queue::{fibonacci_heap::FibonacciHeap, PriorityQueue};
use std::fmt::Debug;
fn test_loop<P>()
where
P: PriorityQueue<u16> + Debug,
{
let mut input = String::new();
let mut p = P::new();
let mut handles = Vec::new();
loop {
input.clear();
let _ = std::io::stdin().read_line(&mut input);
let (cmd, arg) = input.trim().split_once(' ').unwrap_or((input.trim(), ""));
// dbg!(cmd, arg);
match cmd {
"i" => handles.push(p.insert(arg.parse::<u16>().unwrap())),
"m" => println!("{:?}", p.pop_min()),
"d" => {
let (a, b) = arg.split_once(' ').unwrap();
let h = &handles[a.parse::<usize>().unwrap()];
let n = b.parse::<u16>().unwrap();
p.decrease_key(h, |f| *f = n);
}
"p" => {
dbg!(&p);
}
_ => println!("Unknown command."),
}
}
}
fn main() {
test_loop::<FibonacciHeap<u16>>()
}