move get_index to misc.rs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use super::{
|
||||
bitboard::BitBoard,
|
||||
misc::get_index,
|
||||
misc::{diag_raw, split_from},
|
||||
piece::Piece,
|
||||
};
|
||||
@@ -20,10 +21,6 @@ type ChainCollection = ArrayVec<Chain, 8>;
|
||||
pub struct PosMap<T: Default>(ArrayVec<T, { Board::BOARD_AREA }>);
|
||||
|
||||
impl<T: Default> PosMap<T> {
|
||||
const fn index(row: usize, col: usize) -> usize {
|
||||
row * Board::BOARD_SIZE + col
|
||||
}
|
||||
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Self {
|
||||
Self(ArrayVec::from_iter(
|
||||
@@ -32,7 +29,7 @@ impl<T: Default> PosMap<T> {
|
||||
}
|
||||
|
||||
pub fn get(&self, row: usize, col: usize) -> &T {
|
||||
let index = Self::index(row, col);
|
||||
let index = get_index(row, col);
|
||||
|
||||
debug_assert!(
|
||||
Board::BOARD_AREA + 1 >= index,
|
||||
@@ -44,7 +41,7 @@ impl<T: Default> PosMap<T> {
|
||||
}
|
||||
|
||||
pub fn set(&mut self, row: usize, col: usize, value: T) {
|
||||
let index = Self::index(row, col);
|
||||
let index = get_index(row, col);
|
||||
debug_assert!(
|
||||
Board::BOARD_AREA + 1 >= index,
|
||||
"index out of range, was: {}",
|
||||
|
||||
Reference in New Issue
Block a user