use std::hash::Hash;
use crate::{point_f, Point};
#[derive(Clone)]
pub struct FinderPattern {
value: u32,
startEnd: [usize; 2],
resultPoints: Vec<Point>,
}
impl FinderPattern {
pub fn new(value: u32, startEnd: [usize; 2], start: usize, end: usize, rowNumber: u32) -> Self {
Self {
value,
startEnd,
resultPoints: vec![
point_f(start as f32, rowNumber as f32),
point_f(end as f32, rowNumber as f32),
],
}
}
pub fn getValue(&self) -> u32 {
self.value
}
pub fn getStartEnd(&self) -> &[usize] {
&self.startEnd
}
#[cfg(test)]
pub(crate) fn getStartEndMut(&mut self) -> &mut [usize] {
&mut self.startEnd
}
pub fn getPoints(&self) -> &[Point] {
&self.resultPoints
}
}
impl PartialEq for FinderPattern {
fn eq(&self, other: &Self) -> bool {
self.value == other.value
}
}
impl Eq for FinderPattern {}
impl Hash for FinderPattern {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.value.hash(state);
}
}