Struct id_set::IdSet
[−]
[src]
pub struct IdSet { /* fields omitted */ }A set of usize elements represented by a bit vector. Storage required is proportional to the
maximum element in the set.
Methods
impl IdSet[src]
fn new() -> Self
Creates an empty IdSet.
fn new_filled(n: usize) -> Self
Creates a IdSet filled with all elements from 0 to n.
fn with_capacity(n: usize) -> Self
Creates a empty IdSet that can hold elements up to n before reallocating.
fn len(&self) -> usize
Returns the number of distinct elements in the set.
fn is_empty(&self) -> bool
Returns true if the set is empty.
fn capacity(&self) -> usize
Returns capacity of the set. Inserting any elements less than this will not cause reallocation.
fn reserve(&mut self, cap: usize)
Resizes the set such that capacity() >= cap.
fn shrink_to_fit(&mut self)
Resizes the set to minimise allocated memory.
fn clear(&mut self)
Removes all elements from the set.
fn insert(&mut self, id: Id) -> bool
Inserts the given element into the set, returning true if it was not already in the set.
fn remove(&mut self, id: Id) -> bool
Removes the given element from the set, returning true if it was in the set.
fn contains(&self, id: Id) -> bool
Returns true if the given element is in the set.
fn retain<F: FnMut(Id) -> bool>(&mut self, pred: F)
Remove all elements that don't satisfy the predicate.
fn as_blocks(&self) -> &[Block]
Returns the underlying blocks as a slice.
fn iter(&self) -> Iter
An iterator over all elements in increasing order.
fn blocks(&self) -> Blocks
Returns an iterator over the blocks of the underlying representation.
fn into_blocks(self) -> IntoBlocks
Returns a consuming iterator over the blocks of the underlying representation.
fn union<I>(&self, other: I) -> BlockIter<Union<Blocks, I::Blocks>> where
I: IntoBlockIterator,
I: IntoBlockIterator,
Takes the union of the set with another. Equivalent to self | other.
fn intersection<I>(
&self,
other: I
) -> BlockIter<Intersection<Blocks, I::Blocks>> where
I: IntoBlockIterator,
&self,
other: I
) -> BlockIter<Intersection<Blocks, I::Blocks>> where
I: IntoBlockIterator,
Takes the intersection of the set with another. Equivalent to self & other.
fn difference<I>(&self, other: I) -> BlockIter<Difference<Blocks, I::Blocks>> where
I: IntoBlockIterator,
I: IntoBlockIterator,
Takes the difference of the set with another. Equivalent to self - other.
fn symmetric_difference<I>(
&self,
other: I
) -> BlockIter<SymmetricDifference<Blocks, I::Blocks>> where
I: IntoBlockIterator,
&self,
other: I
) -> BlockIter<SymmetricDifference<Blocks, I::Blocks>> where
I: IntoBlockIterator,
Takes the symmetric difference of the set with another. Equivalent to self ^ other.
fn into_union<I>(self, other: I) -> BlockIter<Union<IntoBlocks, I::Blocks>> where
I: IntoBlockIterator,
I: IntoBlockIterator,
Consumes the set and takes the union with another.
fn into_intersection<I>(
self,
other: I
) -> BlockIter<Intersection<IntoBlocks, I::Blocks>> where
I: IntoBlockIterator,
self,
other: I
) -> BlockIter<Intersection<IntoBlocks, I::Blocks>> where
I: IntoBlockIterator,
Consumes the set and takes the intersection with another.
fn into_difference<I>(
self,
other: I
) -> BlockIter<Difference<IntoBlocks, I::Blocks>> where
I: IntoBlockIterator,
self,
other: I
) -> BlockIter<Difference<IntoBlocks, I::Blocks>> where
I: IntoBlockIterator,
Consumes the set and takes the difference with another.
fn into_symmetric_difference<I>(
self,
other: I
) -> BlockIter<SymmetricDifference<IntoBlocks, I::Blocks>> where
I: IntoBlockIterator,
self,
other: I
) -> BlockIter<SymmetricDifference<IntoBlocks, I::Blocks>> where
I: IntoBlockIterator,
Consumes the set and takes the symmetric difference with another.
fn inplace_union<I>(&mut self, other: I) where
I: IntoBlockIterator,
I: IntoBlockIterator,
Take the union of the set inplace with another set. Equivalent to *self |= other.
fn inplace_intersection<I>(&mut self, other: I) where
I: IntoBlockIterator,
I: IntoBlockIterator,
Take the intersection of the set inplace with another set. Equivalent to *self &= other.
fn inplace_difference<I>(&mut self, other: I) where
I: IntoBlockIterator,
I: IntoBlockIterator,
Take the difference of the set inplace with another set. Equivalent to *self -= other.
fn inplace_symmetric_difference<I>(&mut self, other: I) where
I: IntoBlockIterator,
I: IntoBlockIterator,
Take the symmetric difference of the set inplace with another set. Equivalent to
*self ^= other.
fn is_disjoint(&self, other: &Self) -> bool
Returns true if the sets are disjoint.
fn is_superset(&self, other: &Self) -> bool
Returns true if self is a superset of other.
fn is_subset(&self, other: &Self) -> bool
Returns true if self is a subset of other.
Trait Implementations
impl Clone for IdSet[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
impl Debug for IdSet[src]
impl Default for IdSet[src]
impl Eq for IdSet[src]
impl PartialEq for IdSet[src]
fn eq(&self, other: &Self) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0
This method tests for !=.
impl Extend<Id> for IdSet[src]
fn extend<I: IntoIterator<Item = Id>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
impl FromIterator<Id> for IdSet[src]
fn from_iter<I: IntoIterator<Item = Id>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<'a> IntoIterator for &'a IdSet[src]
type Item = Id
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl IntoIterator for IdSet[src]
type Item = Id
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a> IntoBlockIterator for &'a IdSet[src]
type Blocks = Blocks<'a>
The raw iterator type.
fn into_block_iter(self) -> BlockIter<Self::Blocks>
Creates a block iterator.
impl IntoBlockIterator for IdSet[src]
type Blocks = IntoBlocks
The raw iterator type.
fn into_block_iter(self) -> BlockIter<Self::Blocks>
Creates a block iterator.
impl<'a, I> BitAnd<I> for &'a IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<Intersection<Blocks<'a>, I::Blocks>>
The resulting type after applying the & operator
fn bitand(self, other: I) -> Self::Output
Takes the intersection of two objects.
impl<'a, I> BitOr<I> for &'a IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<Union<Blocks<'a>, I::Blocks>>
The resulting type after applying the | operator
fn bitor(self, other: I) -> Self::Output
Takes the union of two objects.
impl<'a, I> BitXor<I> for &'a IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<SymmetricDifference<Blocks<'a>, I::Blocks>>
The resulting type after applying the ^ operator
fn bitxor(self, other: I) -> Self::Output
Takes the symmetric difference of two objects.
impl<'a, I> Sub<I> for &'a IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<Difference<Blocks<'a>, I::Blocks>>
The resulting type after applying the - operator
fn sub(self, other: I) -> Self::Output
Takes the difference of two objects.
impl<I> BitAnd<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<Intersection<IntoBlocks, I::Blocks>>
The resulting type after applying the & operator
fn bitand(self, other: I) -> Self::Output
Takes the intersection of two objects.
impl<I> BitOr<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<Union<IntoBlocks, I::Blocks>>
The resulting type after applying the | operator
fn bitor(self, other: I) -> Self::Output
Takes the union of two objects.
impl<I> BitXor<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<SymmetricDifference<IntoBlocks, I::Blocks>>
The resulting type after applying the ^ operator
fn bitxor(self, other: I) -> Self::Output
Takes the symmetric difference of two objects.
impl<I> Sub<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
type Output = BlockIter<Difference<IntoBlocks, I::Blocks>>
The resulting type after applying the - operator
fn sub(self, other: I) -> Self::Output
Takes the difference of two objects.
impl<I> BitAndAssign<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
fn bitand_assign(&mut self, other: I)
Takes the inplace intersection of the set with another.
impl<I> BitOrAssign<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
fn bitor_assign(&mut self, other: I)
Takes the inplace union of the set with another.
impl<I> BitXorAssign<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
fn bitxor_assign(&mut self, other: I)
Takes the inplace symmetric difference of the set with another.
impl<I> SubAssign<I> for IdSet where
I: IntoBlockIterator, [src]
I: IntoBlockIterator,
fn sub_assign(&mut self, other: I)
Takes the inplace difference of the set with another.