[−][src]Struct bitvector::BitVector
Bitvector
Methods
impl BitVector
[src]
pub fn new(bits: usize) -> Self
[src]
Build a new empty bitvector
pub fn ones(bits: usize) -> Self
[src]
new bitvector contains all elements
If bits % 64 > 0
, the last u64 is guaranteed not to
have any extra 1 bits.
pub fn is_empty(&self) -> bool
[src]
return if this set is empty
if set does not contain any elements, return true; else return false.
This method is averagely faster than self.len() > 0
.
pub fn len(&self) -> usize
[src]
the number of elements in set
pub fn clear(&mut self)
[src]
Clear all elements from a bitvector
pub fn contains(&self, bit: usize) -> bool
[src]
If bit
belongs to set, return true
, else return false
.
Insert, remove and contains do not do bound check.
pub fn eq_left(&self, other: &BitVector, bit: usize) -> bool
[src]
compare if the following is true:
self \cap {0, 1, ... , bit - 1} == other \cap {0, 1, ... ,bit - 1}
for example:
use bitvector::*; let mut A = BitVector::new(11); let mut B = BitVector::new(11); for i in vec![0, 1, 3 ,5 ,7, 10] { A.insert(i); } for i in vec![0, 1, 3, 4, 5, 7, 10] { B.insert(i); } assert!(A.eq_left(&B, 1)); // [0 ] = [0 ] assert!(A.eq_left(&B, 2)); // [0, 1 ] = [0, 1 ] assert!(A.eq_left(&B, 3)); // [0, 1 ] = [0, 1 ] assert!(A.eq_left(&B, 4)); // [0, 1, 3 ] = [0, 1, 3 ] assert!(!A.eq_left(&B, 5)); // [0, 1, 3 ] != [0, 1, 3, 4 ] assert!(!A.eq_left(&B, 6)); // [0, 1, 3, 5] != [0, 1, 3, 4, 5]
pub fn insert(&mut self, bit: usize) -> bool
[src]
insert a new element to set
If value is inserted, return true, if value already exists in set, return false.
Insert, remove and contains do not do bound check.
pub fn remove(&mut self, bit: usize) -> bool
[src]
remove an element from set
If value is removed, return true, if value doesn't exist in set, return false.
Insert, remove and contains do not do bound check.
pub fn insert_all(&mut self, all: &BitVector) -> bool
[src]
import elements from another bitvector
If any new value is inserted, return true, else return false.
pub fn capacity(&self) -> usize
[src]
the max number of elements can be inserted into set
pub fn union(&self, other: &BitVector) -> BitVector
[src]
set union
pub fn intersection(&self, other: &BitVector) -> BitVector
[src]
set intersection
pub fn difference(&self, other: &BitVector) -> BitVector
[src]
set difference
pub fn difference_d(&self, other: &BitVector) -> BitVector
[src]
pub fn union_inplace(&mut self, other: &BitVector) -> &mut BitVector
[src]
Union operator by modifying self
No extra memory allocation
pub fn intersection_inplace(&mut self, other: &BitVector) -> &mut BitVector
[src]
Intersection operator by modifying self
No extra memory allocation
pub fn difference_inplace(&mut self, other: &BitVector) -> &mut BitVector
[src]
Difference operator by modifying self
No extra memory allocation
pub fn difference_d_inplace(&mut self, other: &BitVector) -> &mut BitVector
[src]
ⓘImportant traits for BitVectorIter<'a>pub fn iter<'a>(&'a self) -> BitVectorIter<'a>
[src]
Return a iterator of element based on current bitvector, for example:
extern crate bitvector; use bitvector::*; fn main() { let mut bitvec = BitVector::new(5); bitvec.insert(2); bitvec.insert(3); // The bitvector becomes: 0x00 0x00 0x00 0x0C assert_eq!(bitvec.iter().collect::<Vec<_>>(), vec![2,3]); // collected vector will contains the real element not the bit. }
Trait Implementations
impl IntoIterator for BitVector
[src]
type Item = usize
The type of the elements being iterated over.
type IntoIter = BitVectorIntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> IntoIterator for &'a BitVector
[src]
type Item = usize
The type of the elements being iterated over.
type IntoIter = BitVectorIter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> IntoIterator for &'a mut BitVector
[src]
type Item = usize
The type of the elements being iterated over.
type IntoIter = BitVectorIter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl Clone for BitVector
[src]
impl PartialEq<BitVector> for BitVector
[src]
impl Debug for BitVector
[src]
impl Display for BitVector
[src]
impl<'a> BitAnd<&'a BitVector> for &'a BitVector
[src]
type Output = BitVector
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> BitVector
[src]
impl BitAnd<BitVector> for BitVector
[src]
type Output = BitVector
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> BitVector
[src]
impl<'a> BitOr<&'a BitVector> for &'a BitVector
[src]
type Output = BitVector
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> BitVector
[src]
impl BitOr<BitVector> for BitVector
[src]
type Output = BitVector
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> BitVector
[src]
impl<'a> BitXor<&'a BitVector> for &'a BitVector
[src]
type Output = BitVector
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: Self) -> BitVector
[src]
impl BitXor<BitVector> for BitVector
[src]
type Output = BitVector
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: Self) -> BitVector
[src]
impl<'a> BitAndAssign<&'a mut BitVector> for &'a mut BitVector
[src]
fn bitand_assign(&mut self, rhs: Self)
[src]
impl BitAndAssign<BitVector> for BitVector
[src]
fn bitand_assign(&mut self, rhs: Self)
[src]
impl<'a> BitOrAssign<&'a mut BitVector> for &'a mut BitVector
[src]
fn bitor_assign(&mut self, rhs: Self)
[src]
impl BitOrAssign<BitVector> for BitVector
[src]
fn bitor_assign(&mut self, rhs: Self)
[src]
impl<'a> BitXorAssign<&'a mut BitVector> for &'a mut BitVector
[src]
fn bitxor_assign(&mut self, rhs: Self)
[src]
impl BitXorAssign<BitVector> for BitVector
[src]
fn bitxor_assign(&mut self, rhs: Self)
[src]
impl FromIterator<u8> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = u8>,
[src]
I: IntoIterator<Item = u8>,
impl FromIterator<u16> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = u16>,
[src]
I: IntoIterator<Item = u16>,
impl FromIterator<u32> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = u32>,
[src]
I: IntoIterator<Item = u32>,
impl FromIterator<u64> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = u64>,
[src]
I: IntoIterator<Item = u64>,
impl FromIterator<usize> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = usize>,
[src]
I: IntoIterator<Item = usize>,
impl FromIterator<i8> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = i8>,
[src]
I: IntoIterator<Item = i8>,
impl FromIterator<i16> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = i16>,
[src]
I: IntoIterator<Item = i16>,
impl FromIterator<i32> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = i32>,
[src]
I: IntoIterator<Item = i32>,
impl FromIterator<i64> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = i64>,
[src]
I: IntoIterator<Item = i64>,
impl FromIterator<isize> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = isize>,
[src]
I: IntoIterator<Item = isize>,
impl FromIterator<bool> for BitVector
[src]
fn from_iter<I>(iter: I) -> BitVector where
I: IntoIterator<Item = bool>,
[src]
I: IntoIterator<Item = bool>,
Auto Trait Implementations
impl Send for BitVector
impl Sync for BitVector
impl Unpin for BitVector
impl UnwindSafe for BitVector
impl RefUnwindSafe for BitVector
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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 = !
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<U> 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> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> 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,