pub struct BoolVec { /* private fields */ }Expand description
A vector of boolean values.
Implementations§
Source§impl BoolVec
impl BoolVec
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new, empty BoolVec. The BoolVec will not allocate until elements
are pushed onto it.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Constructs a new, empty BoolVec with the specified capacity.
The BoolVec will be able to hold exactly capacity * 8 booleans without
reallocating. If capacity is 0, the BoolVec will not allocate.
Sourcepub fn filled_with(count: usize, value: bool) -> Self
pub fn filled_with(count: usize, value: bool) -> Self
Creates a new BoolVec containing count booleans set to value.
Sourcepub fn count(&self) -> usize
pub fn count(&self) -> usize
Returns the number of booleans that are stored inside of this BoolVec.
Sourcepub fn reserve(&mut self, additional_capacity: usize)
pub fn reserve(&mut self, additional_capacity: usize)
Identical to Vec::reserve.
additional_capacity is in bytes.
Sourcepub fn reserve_exact(&mut self, additional_capacity: usize)
pub fn reserve_exact(&mut self, additional_capacity: usize)
Identical to Vec::reserve_exact.
additional_capacity is in bytes.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Identical to Vec::shrink_to_fit.
Sourcepub fn truncate(&mut self, count: usize)
pub fn truncate(&mut self, count: usize)
Shortens the BoolVec, keeping the first count boolean values and
dropping the rest.
If count is greater or equal to self.count(), this will have
no effect.
Sourcepub unsafe fn get_unchecked_ref(&self, nth: usize) -> RefBool<'_>
pub unsafe fn get_unchecked_ref(&self, nth: usize) -> RefBool<'_>
Gets a reference to the nth boolean stored inside of this BoolVec.
§Safety
No bound checks are made.
Sourcepub unsafe fn get_unchecked(&self, nth: usize) -> bool
pub unsafe fn get_unchecked(&self, nth: usize) -> bool
Gets the nth boolean stored inside of this BoolVec.
§Safety
The value of nth must be less than self.count().
Sourcepub fn get_ref(&self, nth: usize) -> Option<RefBool<'_>>
pub fn get_ref(&self, nth: usize) -> Option<RefBool<'_>>
Gets a reference to the nth boolean stored inside of this BoolVec
or None if nth is out of bounds.
Sourcepub fn get(&self, nth: usize) -> Option<bool>
pub fn get(&self, nth: usize) -> Option<bool>
Gets the the nth boolean stored inside of this BoolVec or None if
nth is out of bounds.
Sourcepub unsafe fn get_unchecked_mut(&mut self, nth: usize) -> RefBoolMut<'_>
pub unsafe fn get_unchecked_mut(&mut self, nth: usize) -> RefBoolMut<'_>
Gets a mutable reference to the nth boolean stored inside of
this BoolVec.
§Safety
The value of nth must be less than self.count().
Sourcepub fn get_mut(&mut self, nth: usize) -> Option<RefBoolMut<'_>>
pub fn get_mut(&mut self, nth: usize) -> Option<RefBoolMut<'_>>
Gets a mutable reference to the nth boolean stored inside of
this BoolVec or None if nth is out of bounds.
Sourcepub unsafe fn set_unchecked(&mut self, nth: usize, value: bool)
pub unsafe fn set_unchecked(&mut self, nth: usize, value: bool)
Sets the value of the nth boolean stored inside of this BoolVec.
§Safety
The value of nth must be less than self.count()
Sourcepub fn set(&mut self, nth: usize, value: bool)
pub fn set(&mut self, nth: usize, value: bool)
Sets the value of the nth boolean stored inside of this BoolVec.
§Panics
This function panics if nth is greater or equal to self.count().
Sourcepub fn push(&mut self, value: bool)
pub fn push(&mut self, value: bool)
Pushes a new boolean value into this BoolVec.
§Panics
The function panics if the number of bytes allocated overflows usize.
Sourcepub fn pop(&mut self) -> Option<bool>
pub fn pop(&mut self) -> Option<bool>
Removes the last boolean value from this BoolVec and returns it.
Sourcepub fn last_ref(&self) -> Option<RefBool<'_>>
pub fn last_ref(&self) -> Option<RefBool<'_>>
Gets a reference to the last boolean stored in this BoolVec or None
if the BoolVec is empty.
Sourcepub fn last_mut(&mut self) -> Option<RefBoolMut<'_>>
pub fn last_mut(&mut self) -> Option<RefBoolMut<'_>>
Gets a mutable reference to the last boolean stored in this BoolVec
or None if the BoolVec is empty.
Sourcepub fn last(&self) -> Option<bool>
pub fn last(&self) -> Option<bool>
Gets the last boolean stored in this BoolVec or None if the vetor
is empty.
Sourcepub fn iter(&self) -> Iter<'_> ⓘ
pub fn iter(&self) -> Iter<'_> ⓘ
Creates a new iterator that iterates over the values of this BoolVec.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
Creates a new iterator that iterates over mutable references of the
values of this BoolVec.
Sourcepub fn bytes(&self) -> impl Iterator<Item = &u8>
pub fn bytes(&self) -> impl Iterator<Item = &u8>
Returns an iterator over the bytes of this BoolVec.
Sourcepub fn bytes_mut(&mut self) -> impl Iterator<Item = &mut u8>
pub fn bytes_mut(&mut self) -> impl Iterator<Item = &mut u8>
Returns an iterator over the bytes of this BoolVec.
Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Returns the number of bits that are set to 1 within this vector.
Trait Implementations§
Source§impl<'s> BitAndAssign<&'s BoolVec> for BoolVec
impl<'s> BitAndAssign<&'s BoolVec> for BoolVec
Source§fn bitand_assign(&mut self, other: &'s BoolVec)
fn bitand_assign(&mut self, other: &'s BoolVec)
&= operation. Read moreSource§impl<'s> BitOrAssign<&'s BoolVec> for BoolVec
impl<'s> BitOrAssign<&'s BoolVec> for BoolVec
Source§fn bitor_assign(&mut self, other: &'s BoolVec)
fn bitor_assign(&mut self, other: &'s BoolVec)
|= operation. Read moreSource§impl<'s> BitXorAssign<&'s BoolVec> for BoolVec
impl<'s> BitXorAssign<&'s BoolVec> for BoolVec
Source§fn bitxor_assign(&mut self, other: &'s BoolVec)
fn bitxor_assign(&mut self, other: &'s BoolVec)
^= operation. Read more