misc bitboard implementation
This commit is contained in:
parent
e44ddca8e1
commit
57b78880f2
1 changed files with 8 additions and 12 deletions
|
|
@ -157,18 +157,6 @@ impl Iterator for Bitboard {
|
||||||
(len, Some(len))
|
(len, Some(len))
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn for_each<F>(self, mut f: F)
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
F: FnMut(Self::Item),
|
|
||||||
{
|
|
||||||
let mut mask = self.0;
|
|
||||||
while mask != 0 {
|
|
||||||
f(unsafe { Square::new_unchecked(mask.trailing_zeros() as u8) });
|
|
||||||
mask &= mask.wrapping_sub(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
fn fold<B, F>(self, init: B, mut f: F) -> B
|
fn fold<B, F>(self, init: B, mut f: F) -> B
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
|
@ -184,6 +172,14 @@ impl Iterator for Bitboard {
|
||||||
}
|
}
|
||||||
acc
|
acc
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
fn for_each<F>(self, mut f: F)
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
F: FnMut(Self::Item),
|
||||||
|
{
|
||||||
|
self.fold((), |_, square| f(square));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl core::iter::FusedIterator for Bitboard {}
|
impl core::iter::FusedIterator for Bitboard {}
|
||||||
impl core::iter::ExactSizeIterator for Bitboard {
|
impl core::iter::ExactSizeIterator for Bitboard {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue