[−][src]Struct cbitset::BitSet
The bit set itself
This wrapper is #![repr(transparent)]
and guaranteed to have the same memory
representation as the inner bit array
Panics
All non-try functions taking a bit parameter panics if the bit is bigger
than the capacity of the set. For non-panicking versions, use try_
.
Methods
impl<T: BitArray> BitSet<T>
[src]
pub fn new() -> Self
[src]
Create an empty instance
pub fn from_ref(inner: &mut T) -> &mut Self
[src]
Transmutes a reference to a borrowed bit array to a borrowed BitSet with the same lifetime
pub fn into_inner(self) -> T
[src]
Return the inner integer array
pub fn capacity() -> usize
[src]
Returns the capacity of the set, in other words how many bits it can hold. This function may very well overflow if the size or length is too big, but if you're making that big allocations you probably got bigger things to worry about.
pub fn insert(&mut self, bit: usize)
[src]
Enable the value bit
in the set.
If bit
is already enabled this is a no-op.
pub fn try_insert(&mut self, bit: usize) -> bool
[src]
Like insert, but does not panic if the bit is too large. See the struct level documentation for notes on panicking.
pub fn remove(&mut self, bit: usize)
[src]
Disable the value bit
in the set.
If bit
is already disabled this is a no-op.
pub fn try_remove(&mut self, bit: usize) -> bool
[src]
Like remove, but does not panic if the bit is too large. See the struct level documentation for notes on panicking.
pub fn contains(&self, bit: usize) -> bool
[src]
Returns true if the bit bit
is enabled.
If the bit is out of bounds this silently returns false.
pub fn try_contains(&self, bit: usize) -> Option<bool>
[src]
Returns true if the bit bit
is enabled.
pub fn count_ones(&self) -> u32
[src]
Returns the total number of enabled bits
pub fn count_zeros(&self) -> u32
[src]
Returns the total number of disabled bits
pub fn clear(&mut self)
[src]
Disable all bits in a range.
pub fn fill<R: RangeBounds<usize>>(&mut self, range: R, on: bool)
[src]
Set all bits in a range.
fill(.., false)
is effectively the same as clear()
.
Panics
Panics if the start or end bounds are more than the capacity.
Trait Implementations
impl<T: Copy + BitArray> Copy for BitSet<T>
[src]
impl<T: BitArray> From<T> for BitSet<T>
[src]
impl<T: Clone + BitArray> Clone for BitSet<T>
[src]
fn clone(&self) -> BitSet<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Default + BitArray> Default for BitSet<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,