1use std::cmp::Ordering;
2
3pub(crate) mod counts;
4pub(crate) mod lengths;
5
6pub use lengths::{PerPartLength, TotalLength};
7
8#[derive(Debug, Clone)]
10pub(crate) struct FrontierItem<Item, Dist> {
11 pub item: Item,
12 pub distance: Dist,
13}
14
15impl<Item, Dist> FrontierItem<Item, Dist> {
16 pub fn new(item: Item, distance: Dist) -> Self {
17 Self { item, distance }
18 }
19}
20
21impl<Item, Dist: PartialEq> PartialEq for FrontierItem<Item, Dist> {
22 fn eq(&self, other: &Self) -> bool {
23 self.distance == other.distance
24 }
25}
26
27impl<Item, Dist: Eq> Eq for FrontierItem<Item, Dist> {}
28
29impl<Item, Dist: Ord> PartialOrd for FrontierItem<Item, Dist> {
30 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
31 Some(self.cmp(other))
32 }
33}
34
35impl<Item, Dist: Ord> Ord for FrontierItem<Item, Dist> {
36 fn cmp(&self, other: &Self) -> Ordering {
37 self.distance.cmp(&other.distance)
38 }
39}
40
41#[derive(Debug, Clone, Copy)]
42pub enum Boundary {
43 Start,
44 End,
45}
46
47pub(crate) fn div_rounding_up(lhs: usize, rhs: usize) -> usize {
49 (lhs + rhs - 1) / rhs
50}