Resolve warnings.
This commit is contained in:
parent
2bf648f657
commit
5575cb134a
6 changed files with 103 additions and 143 deletions
|
|
@ -1,12 +1,9 @@
|
|||
use termcolor::{Color, ColorSpec};
|
||||
|
||||
use crate::belt_finding::{brute_force::BruteforceBuilder, common::Direction};
|
||||
use crate::graph::wheighted_graph::shortest_path::dijkstra;
|
||||
use crate::graph::wheighted_graph::WheightedGraph;
|
||||
use crate::misc::Map;
|
||||
use crate::priority_queue::BinaryHeap;
|
||||
use std::fmt::Display;
|
||||
use std::ops::{Deref, Index};
|
||||
use std::ops::Index;
|
||||
use termcolor::{Color, ColorSpec};
|
||||
|
||||
use self::common::{print_map, Position, PositionType};
|
||||
|
||||
|
|
@ -88,29 +85,8 @@ impl Problem {
|
|||
self.map.get_mut(p.x as usize, p.y as usize).wheight += 200.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static COLORS: Cyclic<Color, 6> = Cyclic([
|
||||
Color::Red,
|
||||
Color::Green,
|
||||
Color::Yellow,
|
||||
Color::Blue,
|
||||
Color::Magenta,
|
||||
Color::Cyan,
|
||||
]);
|
||||
|
||||
struct Cyclic<T, const N: usize>([T; N]);
|
||||
|
||||
impl<T, const N: usize> Index<usize> for Cyclic<T, N> {
|
||||
type Output = T;
|
||||
|
||||
fn index(&self, index: usize) -> &Self::Output {
|
||||
&self.0[index % N]
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Problem {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
pub fn print(&self) {
|
||||
print_map(self.map.width as i32, self.map.height as i32, |x, y| {
|
||||
let mut color = ColorSpec::new();
|
||||
if let Some(i) = self
|
||||
|
|
@ -152,8 +128,25 @@ impl Display for Problem {
|
|||
(color, " ")
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
static COLORS: Cyclic<Color, 6> = Cyclic([
|
||||
Color::Red,
|
||||
Color::Green,
|
||||
Color::Yellow,
|
||||
Color::Blue,
|
||||
Color::Magenta,
|
||||
Color::Cyan,
|
||||
]);
|
||||
|
||||
struct Cyclic<T, const N: usize>([T; N]);
|
||||
|
||||
impl<T, const N: usize> Index<usize> for Cyclic<T, N> {
|
||||
type Output = T;
|
||||
|
||||
fn index(&self, index: usize) -> &Self::Output {
|
||||
&self.0[index % N]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue