[−][src]Struct bittyset::BitSet
A BitSet
type based on bit vectors.
T
is an unsigned integer type for the underlying bit vector.
Implementations
impl<T> BitSet<T> where
T: BitBlock,
[src]
T: BitBlock,
pub fn new() -> Self
[src]
Creates a new empty BitSet
.
Examples
use bittyset::BitSet; let set = <BitSet>::new(); assert!(set.is_empty());
pub fn with_capacity(capacity: usize) -> Self
[src]
Creates a new empty BitSet
with the given capacity for the underlying
bit vector.
Note that the actual capacity of the created BitSet
may be greater than
the given capacity
, to make best use of the space of the underlying bit
vector.
Examples
use bittyset::BitSet; let set = BitSet::<u8>::with_capacity(5); assert_eq!(set.capacity(), 8);
pub fn capacity(&self) -> usize
[src]
Returns the capacity of the underlying bit vector.
Examples
use bittyset::BitSet; let mut set = BitSet::<u8>::with_capacity(14); assert_eq!(set.capacity(), 16);
pub fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
more bits for the underlying bit
vector.
Examples
use bittyset::bitset; let mut set = bitset![1]; set.reserve(10); assert!(set.capacity() >= 11);
pub fn reserve_exact(&mut self, additional: usize)
[src]
Reserve capacity for exactly additional
more bits for the underlying bit
vector.
Examples
use bittyset::bitset; let mut set = bitset![1]; set.reserve_exact(10); assert!(set.capacity() >= 11);
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity of the underlying bit vector as much as possible.
Examples
use bittyset::BitSet; let mut set = BitSet::<u8>::with_capacity(30); set.extend([1, 2, 3].iter().cloned()); assert_eq!(set.capacity(), 32); set.shrink_to_fit(); assert!(set.capacity() >= 8);
pub fn iter(&self) -> Iter<'_, T>ⓘ
[src]
Iterates over the BitSet
, producing usize
s representing the elements
in the set, in ascending order.
Examples
use bittyset::bitset; let set1 = bitset![7,3,5,18]; let vec1 = set1.iter().collect::<Vec<usize>>(); assert_eq!(vec1, vec![3,5,7,18]);
pub fn len(&self) -> usize
[src]
Returns the number of elements in the set.
pub fn is_empty(&self) -> bool
[src]
Returns whether the set is empty.
pub fn clear(&mut self)
[src]
Clear the set, removing all elements.
Note that this method has no effect on the allocated capacity of the underlying bit vector.
pub fn contains(&self, value: usize) -> bool
[src]
Returns whether the given value
is present in the set.
Examples
use bittyset::bitset; let mut set1 = bitset![7,3,5,18]; assert!(set1.contains(18)); assert!(!set1.contains(4));
pub fn insert(&mut self, value: usize) -> bool
[src]
Adds a value to the set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned.
Examples
use bittyset::bitset; let mut set1 = bitset![7,3,5,18]; assert!(set1.insert(13)); assert!(!set1.insert(5));
pub fn remove(&mut self, value: usize) -> bool
[src]
Removes a value from the set. Returns whether the value was present in the set.
Examples
use bittyset::bitset; let mut set1 = bitset![7,3,5,18]; assert!(set1.remove(3)); assert!(!set1.remove(13));
pub fn union(&self, other: &Self) -> Self
[src]
Computes the union of the set and other
.
A corresponding BitOr implementation is also available, i.e. a | b
.
Examples
use bittyset::bitset; let set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![1,3,5,6,7,18,24]; assert_eq!(set1.union(&set2), set3); assert_eq!(set1 | set2, set3);
pub fn union_with(&mut self, other: &Self)
[src]
Computes the union of the set and other
and then assigns the output to the set.
A corresponding BitOrAssign implementation is also available, i.e. a |= b
.
Examples
use bittyset::bitset; let mut set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![1,3,5,6,7,18,24]; set1.union_with(&set2); assert_eq!(set1, set3);
pub fn intersection(&self, other: &Self) -> Self
[src]
Computes the intersection of the set and other
.
A corresponding BitAnd implementation is also available, i.e. a & b
.
Examples
use bittyset::bitset; let set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![3,7]; assert_eq!(set1.intersection(&set2), set3); assert_eq!(set1 & set2, set3);
pub fn intersect_with(&mut self, other: &Self)
[src]
Computes the intersection of the set and other
and then assigns the
output to the set.
A corresponding BitAndAssign implementation is also available, i.e. a &= b
.
Examples
use bittyset::bitset; let mut set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![3,7]; set1.intersect_with(&set2); assert_eq!(set1, set3);
pub fn difference(&self, other: &Self) -> Self
[src]
Computes the difference of the set and other
.
A corresponding Sub implementation is also available, i.e. a - b
.
Examples
use bittyset::bitset; let set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![5,18]; assert_eq!(set1.difference(&set2), set3); assert_eq!(set1 - set2, set3);
pub fn difference_with(&mut self, other: &Self)
[src]
Computes the difference of the set and other
and then assigns the output
to the set.
A corresponding SubAssign implementation is also available, i.e. a -= b
.
Examples
use bittyset::bitset; let mut set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![5,18]; set1.difference_with(&set2); assert_eq!(set1, set3);
pub fn symmetric_difference(&self, other: &Self) -> Self
[src]
Computes the symmetric difference of the set and other
.
A corresponding BitXor implementation is also available, i.e. a ^ b
.
Examples
use bittyset::bitset; let set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![1,5,6,18,24]; assert_eq!(set1.symmetric_difference(&set2), set3); assert_eq!(set1 ^ set2, set3);
pub fn symmetric_difference_with(&mut self, other: &Self)
[src]
Computes the symmetric difference of the set and other
and then assigns
the output to the set.
A corresponding BitXorAssign implementation is also available, i.e. a ^= b
.
Examples
use bittyset::bitset; let mut set1 = bitset![7,3,5,18]; let set2 = bitset![3,1,6,7,24]; let set3 = bitset![1,5,6,18,24]; set1.symmetric_difference_with(&set2); assert_eq!(set1, set3);
pub fn is_subset(&self, other: &Self) -> bool
[src]
Returns whether the set is a subset of other
.
Examples
use bittyset::bitset; let set1 = bitset![7,3,5,18]; let set2 = bitset![3,5,7,18,41]; assert!(set1.is_subset(&set2)); assert!(!set2.is_subset(&set1));
pub fn is_proper_subset(&self, other: &Self) -> bool
[src]
Returns whether the set is a proper subset of other
.
Examples
use bittyset::bitset; let set1 = bitset![7,3,5,18]; let set2 = bitset![3,5,7,18,41]; assert!(set1.is_proper_subset(&set2)); assert!(!set2.is_proper_subset(&set1)); assert!(!set1.is_proper_subset(&set1));
Trait Implementations
impl<'a, T: BitBlock> BitAnd<&'a BitSet<T>> for &'a BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a BitSet<T>) -> BitSet<T>
[src]
impl<T: BitBlock> BitAnd<BitSet<T>> for BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the &
operator.
fn bitand(self, rhs: BitSet<T>) -> BitSet<T>
[src]
impl<'a, T: BitBlock> BitAndAssign<&'a BitSet<T>> for BitSet<T>
[src]
fn bitand_assign(&mut self, rhs: &'a BitSet<T>)
[src]
impl<T: BitBlock> BitAndAssign<BitSet<T>> for BitSet<T>
[src]
fn bitand_assign(&mut self, rhs: BitSet<T>)
[src]
impl<'a, T: BitBlock> BitOr<&'a BitSet<T>> for &'a BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the |
operator.
fn bitor(self, rhs: &'a BitSet<T>) -> BitSet<T>
[src]
impl<T: BitBlock> BitOr<BitSet<T>> for BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the |
operator.
fn bitor(self, rhs: BitSet<T>) -> BitSet<T>
[src]
impl<'a, T: BitBlock> BitOrAssign<&'a BitSet<T>> for BitSet<T>
[src]
fn bitor_assign(&mut self, rhs: &'a BitSet<T>)
[src]
impl<T: BitBlock> BitOrAssign<BitSet<T>> for BitSet<T>
[src]
fn bitor_assign(&mut self, rhs: BitSet<T>)
[src]
impl<'a, T: BitBlock> BitXor<&'a BitSet<T>> for &'a BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &'a BitSet<T>) -> BitSet<T>
[src]
impl<T: BitBlock> BitXor<BitSet<T>> for BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: BitSet<T>) -> BitSet<T>
[src]
impl<'a, T: BitBlock> BitXorAssign<&'a BitSet<T>> for BitSet<T>
[src]
fn bitxor_assign(&mut self, rhs: &'a BitSet<T>)
[src]
impl<T: BitBlock> BitXorAssign<BitSet<T>> for BitSet<T>
[src]
fn bitxor_assign(&mut self, rhs: BitSet<T>)
[src]
impl<T: Clone> Clone for BitSet<T>
[src]
impl<T> Debug for BitSet<T> where
T: BitBlock,
[src]
T: BitBlock,
impl<T: Default> Default for BitSet<T>
[src]
impl<T: BitBlock> Eq for BitSet<T>
[src]
impl<T: BitBlock> Extend<usize> for BitSet<T>
[src]
fn extend<I: IntoIterator<Item = usize>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<T: BitBlock> FromIterator<usize> for BitSet<T>
[src]
fn from_iter<I: IntoIterator<Item = usize>>(iter: I) -> Self
[src]
impl<T: BitBlock> Hash for BitSet<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, T> IntoIterator for &'a BitSet<T> where
T: BitBlock,
[src]
T: BitBlock,
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
type Item = usize
The type of the elements being iterated over.
fn into_iter(self) -> Self::IntoIter
[src]
impl<T: BitBlock> PartialEq<BitSet<T>> for BitSet<T>
[src]
impl<'a, T: BitBlock> Sub<&'a BitSet<T>> for &'a BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a BitSet<T>) -> BitSet<T>
[src]
impl<T: BitBlock> Sub<BitSet<T>> for BitSet<T>
[src]
type Output = BitSet<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: BitSet<T>) -> BitSet<T>
[src]
impl<'a, T: BitBlock> SubAssign<&'a BitSet<T>> for BitSet<T>
[src]
fn sub_assign(&mut self, rhs: &'a BitSet<T>)
[src]
impl<T: BitBlock> SubAssign<BitSet<T>> for BitSet<T>
[src]
fn sub_assign(&mut self, rhs: BitSet<T>)
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for BitSet<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for BitSet<T> where
T: Send,
T: Send,
impl<T> Sync for BitSet<T> where
T: Sync,
T: Sync,
impl<T> Unpin for BitSet<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for BitSet<T> where
T: UnwindSafe,
T: UnwindSafe,
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,
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,