pub struct Gridbool<P: PosT, const WORDS: usize>(/* private fields */);
Expand description
Space-optimized grid of booleans using bitmaps
Gridbool
uses an array of u32 to implement a Pos
-indexable
grid of booleans, balancing space and performance.
At the moment we need to provide the number of u32 WORDS to use due to rust generic const limitations. We are able to check that the value is appropriate, though.
We can use the gridbool_create
macro to use a Pos
as a
source of these values.
Implementations§
Source§impl<P: PosT, const WORDS: usize> Gridbool<P, WORDS>
impl<P: PosT, const WORDS: usize> Gridbool<P, WORDS>
Sourcepub fn into_inner(self) -> [u32; WORDS]
pub fn into_inner(self) -> [u32; WORDS]
Consume self and returns the inner bitmap.
Sourcepub fn as_inner(&self) -> &[u32; WORDS]
pub fn as_inner(&self) -> &[u32; WORDS]
Return a reference to the inner bitmap; useful for testing.
Sourcepub fn as_inner_mut(&mut self) -> &mut [u32; WORDS]
pub fn as_inner_mut(&mut self) -> &mut [u32; WORDS]
Return a mut reference to the inner bitmap; useful for testing.
Sourcepub fn iter(&self) -> impl Iterator<Item = bool> + '_
pub fn iter(&self) -> impl Iterator<Item = bool> + '_
Iterate over all true
/false
values in the Gridbool
.
Sourcepub fn iter_pos(&self) -> impl Iterator<Item = (P, bool)> + '_where
P: Copy,
pub fn iter_pos(&self) -> impl Iterator<Item = (P, bool)> + '_where
P: Copy,
Iterate over all coordinates and corresponding true
/false
values.
Sourcepub fn iter_t(&self) -> impl Iterator<Item = P> + '_
pub fn iter_t(&self) -> impl Iterator<Item = P> + '_
Iterate over all true
coordinates the Gridbool
.
Sourcepub fn iter_f(&self) -> impl Iterator<Item = P> + '_
pub fn iter_f(&self) -> impl Iterator<Item = P> + '_
Iterate over all false
coordinates the Gridbool
.
Sourcepub fn set_iter_t(&mut self, positer: impl Iterator<Item = P>)
pub fn set_iter_t(&mut self, positer: impl Iterator<Item = P>)
Take a Pos
iterator and set all corresponding values to true
.
Sourcepub fn set_iter_f(&mut self, positer: impl Iterator<Item = P>)
pub fn set_iter_f(&mut self, positer: impl Iterator<Item = P>)
Take a Pos
iterator and set all corresponding values to false
.
Trait Implementations§
Source§impl<P: PosT, const WORDS: usize> FromIterator<P> for Gridbool<P, WORDS>
impl<P: PosT, const WORDS: usize> FromIterator<P> for Gridbool<P, WORDS>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = P>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = P>,
Source§impl<P: Ord + PosT, const WORDS: usize> Ord for Gridbool<P, WORDS>
impl<P: Ord + PosT, const WORDS: usize> Ord for Gridbool<P, WORDS>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<P: PartialOrd + PosT, const WORDS: usize> PartialOrd for Gridbool<P, WORDS>
impl<P: PartialOrd + PosT, const WORDS: usize> PartialOrd for Gridbool<P, WORDS>
Source§impl<P: PosT, const WORDS: usize, const SIZE: usize> SetPos<P, WORDS, SIZE> for Gridbool<P, WORDS>
impl<P: PosT, const WORDS: usize, const SIZE: usize> SetPos<P, WORDS, SIZE> for Gridbool<P, WORDS>
Source§fn insert(&mut self, pos: P)
fn insert(&mut self, pos: P)
super::pos::Pos
Source§fn remove(&mut self, pos: &P)
fn remove(&mut self, pos: &P)
super::pos::Pos
Source§fn set(&mut self, pos: P, add: bool)
fn set(&mut self, pos: P, add: bool)
super::pos::Pos