|
|
@ -18,42 +18,6 @@ enum Side {
|
|
|
|
|
|
|
|
|
|
|
|
fn split(side: Side, lower: &mut i32, upper: &mut i32) -> Option<i32> {
|
|
|
|
fn split(side: Side, lower: &mut i32, upper: &mut i32) -> Option<i32> {
|
|
|
|
match side {
|
|
|
|
match side {
|
|
|
|
/* Side::Left => {
|
|
|
|
|
|
|
|
*upper = ((*upper - *lower + 1) / 2 + *lower);
|
|
|
|
|
|
|
|
//println!("{}, {}", *upper, *lower);
|
|
|
|
|
|
|
|
if (*upper - *lower).abs() == 1 {
|
|
|
|
|
|
|
|
Some(*lower)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Side::Right => {
|
|
|
|
|
|
|
|
*lower = ((*upper - *lower + 1) / 2 + *lower - 1);
|
|
|
|
|
|
|
|
//println!("{}, {}", *upper, *lower);
|
|
|
|
|
|
|
|
if (*upper - *lower).abs() == 1 {
|
|
|
|
|
|
|
|
Some(*upper - 1)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Side::Front => {
|
|
|
|
|
|
|
|
*upper = ((*upper - *lower + 1) / 2 + *lower);
|
|
|
|
|
|
|
|
// println!("{}, {}", *upper, *lower);
|
|
|
|
|
|
|
|
if (*upper - *lower).abs() == 1 {
|
|
|
|
|
|
|
|
Some(*lower)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Side::Back => {
|
|
|
|
|
|
|
|
*lower = ((*upper - *lower + 1) / 2 + *lower);
|
|
|
|
|
|
|
|
//println!("{}, {}", *upper, *lower);
|
|
|
|
|
|
|
|
if (*upper - *lower).abs() == 1 {
|
|
|
|
|
|
|
|
Some(*upper - 1)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
Side::Left => {
|
|
|
|
Side::Left => {
|
|
|
|
if (*upper - *lower).abs() == 1 {
|
|
|
|
if (*upper - *lower).abs() == 1 {
|
|
|
|
Some(*lower)
|
|
|
|
Some(*lower)
|
|
|
|