Fix warnings.

This commit is contained in:
hal8174 2024-03-23 23:52:46 +01:00
parent 8c29cb1e53
commit 1596bf180d
8 changed files with 54 additions and 71 deletions

View file

@ -1,13 +1,12 @@
use crate::graph::wheighted_graph::WheightedGraph;
use crate::misc::Map;
use crate::priority_queue::BinaryHeap;
use crate::{
graph::wheighted_graph::shortest_path::dijkstra, priority_queue::fibonacci_heap::FibonacciHeap,
};
use std::ops::Index;
use termcolor::{Color, ColorSpec};
use self::common::{print_map, Direction, PathField, Position, PositionType};
use self::common::{print_map, Direction, Position, PositionType};
pub mod brute_force;
pub mod common;
@ -89,7 +88,7 @@ impl Problem {
}
pub fn print(&self) {
print_map(self.map.width as i32, self.map.height as i32, |x, y| {
let _ = print_map(self.map.width as i32, self.map.height as i32, |x, y| {
let mut color = ColorSpec::new();
if let Some(i) = self
.start
@ -158,18 +157,13 @@ impl<'a> WheightedGraph for MapInternal<'a> {
fn edge(&self, node: &Self::Node, num: usize) -> Option<(Self::Node, f64)> {
let next = node.0.in_direction(&node.1, 1);
if next
.in_range(
&Position::new(0, 0),
&Position::new(
self.map.width as PositionType,
self.map.height as PositionType,
),
)
.is_none()
{
return None;
}
next.in_range(
&Position::new(0, 0),
&Position::new(
self.map.width as PositionType,
self.map.height as PositionType,
),
)?;
if self.map.get(next.x as usize, next.y as usize).blocked && self.end != (next, node.1) {
return None;
}
@ -183,17 +177,13 @@ impl<'a> WheightedGraph for MapInternal<'a> {
let mut count = 2;
for l in 2..=6 {
let n = node.0.in_direction(&node.1, l);
if n.in_range(
n.in_range(
&Position::new(0, 0),
&Position::new(
self.map.width as PositionType,
self.map.height as PositionType,
),
)
.is_none()
{
return None;
}
)?;
if !self.map.get(n.x as usize, n.y as usize).blocked {
count += 1;
if count == num {