Refactor into different crates
This commit is contained in:
		
							parent
							
								
									94473c64e0
								
							
						
					
					
						commit
						dfdeae5638
					
				
					 82 changed files with 624 additions and 647 deletions
				
			
		|  | @ -1,40 +0,0 @@ | |||
| use factorio_blueprint::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>>() | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue