Struct bitmagic::BVector [−][src]
A bitvector
Implementations
impl BVector
[src]
pub fn new() -> BVector
[src]
Create a new bit-vector container with runtime compression of bits
pub fn with_capacity(capacity: usize) -> BVector
[src]
Create a new bit-vector container with capacity (maximum number of allowed bits).
BitMagic recommends ALWAYS setting the size to maximum, so it is
preferable to use new
instead.
pub fn grow(&mut self, bits: usize)
[src]
Grow capacity to bits, all new bits initialized to zero
pub fn len(&self) -> usize
[src]
Return the length of the BVector in bits.
pub fn is_empty(&self) -> bool
[src]
Check if any bits are set
pub fn contains(&self, bit: usize) -> bool
[src]
Return true if the bit is enabled in the BVector, false otherwise.
Note: bits outside the capacity are always disabled.
Note: Also available with index syntax: bvector[bit]
.
pub fn clear(&mut self)
[src]
Clear all bits.
pub fn insert(&mut self, bit: usize)
[src]
Enable bit
.
Panics if bit is out of bounds.
pub fn put(&mut self, bit: usize) -> bool
[src]
Enable bit
, and return its previous value.
Panics if bit is out of bounds.
pub fn toggle(&mut self, bit: usize)
[src]
Toggle bit
(inverting its state).
Panics if bit is out of bounds
pub fn set(&mut self, bit: usize, enabled: bool)
[src]
Panics if bit is out of bounds.
pub fn copy_bit(&mut self, from: usize, to: usize)
[src]
Copies boolean value from specified bit to the specified bit.
Panics if to is out of bounds.
pub fn count_ones<T: IndexRange>(&self, range: T) -> usize
[src]
Count the number of set bits in the given bit range.
Use ..
to count the whole content of the bitset.
Panics if the range extends past the end of the bitset.
pub fn set_range<T: IndexRange>(&mut self, range: T, enabled: bool)
[src]
Sets every bit in the given range to the given state (enabled
)
Use ..
to set the whole bitset.
Panics if the range extends past the end of the bitset.
pub fn insert_range<T: IndexRange>(&mut self, range: T)
[src]
Enables every bit in the given range.
Use ..
to make the whole bitset ones.
Panics if the range extends past the end of the bitset.
pub fn toggle_range<T: IndexRange>(&mut self, range: T)
[src]
Toggles (inverts) every bit in the given range.
Use ..
to toggle the whole bitset.
Panics if the range extends past the end of the bitset.
pub fn ones(&self) -> Ones<'_>
[src]
Iterates over all enabled bits.
Iterator element is the index of the 1
bit, type usize
.
pub fn intersection<'a>(&'a self, other: &'a BVector) -> Intersection<'a>
[src]
Returns a lazy iterator over the intersection of two BVector
s
pub fn union<'a>(&'a self, other: &'a BVector) -> Union<'a>
[src]
Returns a lazy iterator over the union of two BVector
s.
pub fn difference<'a>(&'a self, other: &'a BVector) -> Difference<'a>
[src]
Returns a lazy iterator over the difference of two BVector
s. The difference of a
and b
is the elements of a
which are not in b
.
pub fn symmetric_difference<'a>(
&'a self,
other: &'a BVector
) -> SymmetricDifference<'a>
[src]
&'a self,
other: &'a BVector
) -> SymmetricDifference<'a>
Returns a lazy iterator over the symmetric difference of two BVector
s.
The symmetric difference of a
and b
is the elements of one, but not both, sets.
pub fn union_with(&mut self, other: &BVector)
[src]
In-place union of two BVector
s.
On calling this method, self
’s capacity may be increased to match other
’s.
pub fn intersect_with(&mut self, other: &BVector)
[src]
In-place intersection of two BVector
s.
On calling this method, self
’s capacity will remain the same as before.
pub fn difference_with(&mut self, other: &BVector)
[src]
In-place difference of two BVector
s.
On calling this method, self
’s capacity will remain the same as before.
pub fn symmetric_difference_with(&mut self, other: &BVector)
[src]
In-place symmetric difference of two BVector
s.
On calling this method, self
’s capacity may be increased to match other
’s.
pub fn is_disjoint(&self, other: &BVector) -> bool
[src]
Returns true
if self
has no elements in common with other
. This
is equivalent to checking for an empty intersection.
pub fn is_subset(&self, other: &BVector) -> bool
[src]
Returns true
if the set is a subset of another, i.e. other
contains
at least all the values in self
.
pub fn is_superset(&self, other: &BVector) -> bool
[src]
Returns true
if the set is a superset of another, i.e. self
contains
at least all the values in other
.
impl BVector
[src]
pub fn serialize<W>(&self, wtr: W) -> Result<(), Box<dyn Error>> where
W: Write,
[src]
W: Write,
Serialize bit vector
pub fn deserialize<R>(rdr: R) -> Result<Self, Box<dyn Error>> where
R: Read,
[src]
R: Read,
Deserialize bit vector
pub fn intersection_count(&self, other: &BVector) -> usize
[src]
Size of the intersection of two BVector
s.
Equivalent to the population count of AND of two bit vectors
pub fn union_count(&self, other: &BVector) -> usize
[src]
Size of the union of two BVector
s.
Equivalent to the population count of OR of two bit vectors
pub fn difference_count(&self, other: &BVector) -> usize
[src]
Size of the difference of two BVector
s.
Equivalent to the population count of SUB of two bit vectors
pub fn symmetric_difference_count(&self, other: &BVector) -> usize
[src]
Size of the symmetric difference of two BVector
s.
Equivalent to the population count of XOR of two bit vectors
Trait Implementations
impl Binary for BVector
[src]
impl<'a> BitAnd<&'a BVector> for &'a BVector
[src]
type Output = BVector
The resulting type after applying the &
operator.
fn bitand(self, other: &BVector) -> BVector
[src]
impl<'a> BitAndAssign<&'_ BVector> for BVector
[src]
fn bitand_assign(&mut self, other: &Self)
[src]
impl<'a> BitAndAssign<BVector> for BVector
[src]
fn bitand_assign(&mut self, other: Self)
[src]
impl<'a> BitOr<&'a BVector> for &'a BVector
[src]
type Output = BVector
The resulting type after applying the |
operator.
fn bitor(self, other: &BVector) -> BVector
[src]
impl<'a> BitOrAssign<&'_ BVector> for BVector
[src]
fn bitor_assign(&mut self, other: &Self)
[src]
impl<'a> BitOrAssign<BVector> for BVector
[src]
fn bitor_assign(&mut self, other: Self)
[src]
impl<'a> BitXor<&'a BVector> for &'a BVector
[src]
type Output = BVector
The resulting type after applying the ^
operator.
fn bitxor(self, other: &BVector) -> BVector
[src]
impl<'a> BitXorAssign<&'_ BVector> for BVector
[src]
fn bitxor_assign(&mut self, other: &Self)
[src]
impl<'a> BitXorAssign<BVector> for BVector
[src]
fn bitxor_assign(&mut self, other: Self)
[src]
impl Clone for BVector
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for BVector
[src]
impl Default for BVector
[src]
impl Display for BVector
[src]
impl Drop for BVector
[src]
impl Extend<usize> for BVector
[src]
Sets the bit at index i to true for each item i in the input src.
fn extend<I: IntoIterator<Item = usize>>(&mut self, src: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl FromIterator<usize> for BVector
[src]
Return a BVector containing bits set to true for every bit index in the iterator, other bits are set to false.
fn from_iter<I: IntoIterator<Item = usize>>(src: I) -> Self
[src]
impl Index<usize> for BVector
[src]
Return true if the bit is enabled in the bitset, or false otherwise.
Note: bits outside the capacity are always disabled, and thus indexing a BVector will not panic.
impl PartialEq<BVector> for BVector
[src]
impl PartialOrd<BVector> for BVector
[src]
Auto Trait Implementations
impl RefUnwindSafe for BVector
impl !Send for BVector
impl !Sync for BVector
impl Unpin for BVector
impl UnwindSafe for BVector
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,