Hide mark_matrix::Mark

This commit is contained in:
Michael Neumann 2015-10-20 13:47:54 +02:00
parent 39fc8be008
commit 7177a250e5
2 changed files with 27 additions and 27 deletions

View File

@ -29,9 +29,6 @@ use square_matrix::SquareMatrix;
use coverage::Coverage; use coverage::Coverage;
use mark_matrix::MarkMatrix; use mark_matrix::MarkMatrix;
#[cfg(test)]
use mark_matrix::Mark;
pub mod square_matrix; pub mod square_matrix;
mod coverage; mod coverage;
mod mark_matrix; mod mark_matrix;
@ -533,15 +530,15 @@ fn test_step4_case2() {
assert_eq!(false, coverage.is_row_covered(2)); assert_eq!(false, coverage.is_row_covered(2));
// starring DID CHANGE! // starring DID CHANGE!
assert_eq!(Mark::Star, marks.get((0,0))); assert_eq!(true, marks.is_star((0,0)));
assert_eq!(Mark::Prime, marks.get((0,1))); assert_eq!(true, marks.is_prime((0,1)));
assert_eq!(Mark::None, marks.get((0,2))); assert_eq!(true, marks.is_none((0,2)));
assert_eq!(Mark::None, marks.get((1,0))); assert_eq!(true, marks.is_none((1,0)));
assert_eq!(Mark::None, marks.get((1,1))); assert_eq!(true, marks.is_none((1,1)));
assert_eq!(Mark::Star, marks.get((1,2))); assert_eq!(true, marks.is_star((1,2)));
assert_eq!(Mark::Prime, marks.get((2,0))); assert_eq!(true, marks.is_prime((2,0)));
assert_eq!(Mark::None, marks.get((2,1))); assert_eq!(true, marks.is_none((2,1)));
assert_eq!(Mark::None, marks.get((2,2))); assert_eq!(true, marks.is_none((2,2)));
} }
#[test] #[test]
@ -574,17 +571,17 @@ fn test_step5() {
assert_eq!(false, coverage.is_row_covered(2)); assert_eq!(false, coverage.is_row_covered(2));
// starring DID CHANGE! // starring DID CHANGE!
assert_eq!(Mark::None, marks.get((0,0))); assert_eq!(true, marks.is_none((0,0)));
assert_eq!(Mark::Star, marks.get((0,1))); assert_eq!(true, marks.is_star((0,1)));
assert_eq!(Mark::None, marks.get((0,2))); assert_eq!(true, marks.is_none((0,2)));
assert_eq!(Mark::None, marks.get((1,0))); assert_eq!(true, marks.is_none((1,0)));
assert_eq!(Mark::None, marks.get((1,1))); assert_eq!(true, marks.is_none((1,1)));
assert_eq!(Mark::Star, marks.get((1,2))); assert_eq!(true, marks.is_star((1,2)));
assert_eq!(Mark::Star, marks.get((2,0))); assert_eq!(true, marks.is_star((2,0)));
assert_eq!(Mark::None, marks.get((2,1))); assert_eq!(true, marks.is_none((2,1)));
assert_eq!(Mark::None, marks.get((2,2))); assert_eq!(true, marks.is_none((2,2)));
} }

View File

@ -1,7 +1,7 @@
use ::square_matrix::SquareMatrix; use ::square_matrix::SquareMatrix;
#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Mark { enum Mark {
None, None,
Star, Star,
Prime Prime
@ -27,11 +27,6 @@ impl MarkMatrix {
} }
} }
#[cfg(test)]
pub fn get(&self, pos: (usize, usize)) -> Mark {
self.marks[pos]
}
pub fn unmark(&mut self, pos: (usize, usize)) { pub fn unmark(&mut self, pos: (usize, usize)) {
self.marks[pos] = Mark::None; self.marks[pos] = Mark::None;
} }
@ -58,6 +53,14 @@ impl MarkMatrix {
} }
} }
#[cfg(test)]
pub fn is_none(&self, pos: (usize, usize)) -> bool {
match self.marks[pos] {
Mark::None => true,
_ => false
}
}
pub fn find_first_star_in_row(&self, row: usize) -> Option<usize> { pub fn find_first_star_in_row(&self, row: usize) -> Option<usize> {
for col in 0..self.n() { for col in 0..self.n() {
if self.is_star((row, col)) { if self.is_star((row, col)) {