com_croftsoft_core/ai/astar/operations/
mod.rs

1// =============================================================================
2//! - Operation implementations for the A* algorithm
3//!
4//! # Metadata
5//! - Copyright: © 2022-2023 [`CroftSoft Inc`]
6//! - Author: [`David Wallace Croft`]
7//! - Java created: 2002-04-21
8//! - Java updated: 2003-05-09
9//! - Rust created: 2022-10-22
10//! - Rust updated: 2023-06-25
11//!
12//! # History
13//! - Adapted from the classes in the Java-based [`CroftSoft Core Library`]
14//!   - com.croftsoft.core.ai.astar.NodeInfo
15//!
16//! [`CroftSoft Core Library`]: https://www.croftsoft.com/library/code/
17//! [`CroftSoft Inc`]: https://www.croftsoft.com/
18//! [`David Wallace Croft`]: https://www.croftsoft.com/people/david/
19// =============================================================================
20
21use super::structures::NodeInfo;
22use std::cmp::Ordering;
23
24#[cfg(test)]
25mod test;
26
27impl PartialEq for NodeInfo {
28  fn eq(
29    &self,
30    other: &Self,
31  ) -> bool {
32    self.total_cost.eq(&other.total_cost)
33  }
34}
35
36impl PartialOrd for NodeInfo {
37  fn lt(
38    &self,
39    other: &Self,
40  ) -> bool {
41    self.total_cost.lt(&other.total_cost)
42  }
43
44  fn le(
45    &self,
46    other: &Self,
47  ) -> bool {
48    self.total_cost.le(&other.total_cost)
49  }
50
51  fn gt(
52    &self,
53    other: &Self,
54  ) -> bool {
55    self.total_cost.gt(&other.total_cost)
56  }
57
58  fn ge(
59    &self,
60    other: &Self,
61  ) -> bool {
62    self.total_cost.ge(&other.total_cost)
63  }
64
65  fn partial_cmp(
66    &self,
67    other: &Self,
68  ) -> Option<Ordering> {
69    self.total_cost.partial_cmp(&other.total_cost)
70  }
71}