pub struct IdSet { /* private fields */ }
Expand description
A set of usize
elements represented by a bit vector. Storage required is proportional to the
maximum element in the set.
Implementations§
Source§impl IdSet
impl IdSet
Sourcepub fn new_filled(n: usize) -> Self
pub fn new_filled(n: usize) -> Self
Creates a IdSet
filled with all elements from 0 to n.
Sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Creates a empty IdSet
that can hold elements up to n before reallocating.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns capacity of the set. Inserting any elements less than this will not cause reallocation.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Resizes the set to minimise allocated memory.
Sourcepub fn insert(&mut self, id: Id) -> bool
pub fn insert(&mut self, id: Id) -> bool
Inserts the given element into the set, returning true if it was not already in the set.
Sourcepub fn remove(&mut self, id: Id) -> bool
pub fn remove(&mut self, id: Id) -> bool
Removes the given element from the set, returning true if it was in the set.
Sourcepub fn retain<F: FnMut(Id) -> bool>(&mut self, pred: F)
pub fn retain<F: FnMut(Id) -> bool>(&mut self, pred: F)
Remove all elements that don’t satisfy the predicate.
Sourcepub fn blocks(&self) -> Blocks<'_> ⓘ
pub fn blocks(&self) -> Blocks<'_> ⓘ
Returns an iterator over the blocks of the underlying representation.
Sourcepub fn into_blocks(self) -> IntoBlocks ⓘ
pub fn into_blocks(self) -> IntoBlocks ⓘ
Returns a consuming iterator over the blocks of the underlying representation.
Sourcepub fn union<I>(&self, other: I) -> BlockIter<Union<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
pub fn union<I>(&self, other: I) -> BlockIter<Union<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
Takes the union of the set with another. Equivalent to self | other
.
Sourcepub fn intersection<I>(
&self,
other: I,
) -> BlockIter<Intersection<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
pub fn intersection<I>(
&self,
other: I,
) -> BlockIter<Intersection<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
Takes the intersection of the set with another. Equivalent to self & other
.
Sourcepub fn difference<I>(
&self,
other: I,
) -> BlockIter<Difference<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
pub fn difference<I>(
&self,
other: I,
) -> BlockIter<Difference<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
Takes the difference of the set with another. Equivalent to self - other
.
Sourcepub fn symmetric_difference<I>(
&self,
other: I,
) -> BlockIter<SymmetricDifference<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
pub fn symmetric_difference<I>(
&self,
other: I,
) -> BlockIter<SymmetricDifference<Blocks<'_>, I::Blocks>>where
I: IntoBlockIterator,
Takes the symmetric difference of the set with another. Equivalent to self ^ other
.
Sourcepub fn into_union<I>(self, other: I) -> BlockIter<Union<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
pub fn into_union<I>(self, other: I) -> BlockIter<Union<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
Consumes the set and takes the union with another.
Sourcepub fn into_intersection<I>(
self,
other: I,
) -> BlockIter<Intersection<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
pub fn into_intersection<I>(
self,
other: I,
) -> BlockIter<Intersection<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
Consumes the set and takes the intersection with another.
Sourcepub fn into_difference<I>(
self,
other: I,
) -> BlockIter<Difference<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
pub fn into_difference<I>(
self,
other: I,
) -> BlockIter<Difference<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
Consumes the set and takes the difference with another.
Sourcepub fn into_symmetric_difference<I>(
self,
other: I,
) -> BlockIter<SymmetricDifference<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
pub fn into_symmetric_difference<I>(
self,
other: I,
) -> BlockIter<SymmetricDifference<IntoBlocks, I::Blocks>>where
I: IntoBlockIterator,
Consumes the set and takes the symmetric difference with another.
Sourcepub fn inplace_union<I>(&mut self, other: I)where
I: IntoBlockIterator,
pub fn inplace_union<I>(&mut self, other: I)where
I: IntoBlockIterator,
Take the union of the set inplace with another set. Equivalent to *self |= other
.
Sourcepub fn inplace_intersection<I>(&mut self, other: I)where
I: IntoBlockIterator,
pub fn inplace_intersection<I>(&mut self, other: I)where
I: IntoBlockIterator,
Take the intersection of the set inplace with another set. Equivalent to *self &= other
.
Sourcepub fn inplace_difference<I>(&mut self, other: I)where
I: IntoBlockIterator,
pub fn inplace_difference<I>(&mut self, other: I)where
I: IntoBlockIterator,
Take the difference of the set inplace with another set. Equivalent to *self -= other
.
Sourcepub fn inplace_symmetric_difference<I>(&mut self, other: I)where
I: IntoBlockIterator,
pub fn inplace_symmetric_difference<I>(&mut self, other: I)where
I: IntoBlockIterator,
Take the symmetric difference of the set inplace with another set. Equivalent to
*self ^= other
.
Sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Returns true if the sets are disjoint.
Sourcepub fn is_superset(&self, other: &Self) -> bool
pub fn is_superset(&self, other: &Self) -> bool
Returns true if self is a superset of other.
Trait Implementations§
Source§impl<'a, I> BitAnd<I> for &'a IdSetwhere
I: IntoBlockIterator,
impl<'a, I> BitAnd<I> for &'a IdSetwhere
I: IntoBlockIterator,
Source§impl<I> BitAnd<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> BitAnd<I> for IdSetwhere
I: IntoBlockIterator,
Source§impl<I> BitAndAssign<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> BitAndAssign<I> for IdSetwhere
I: IntoBlockIterator,
Source§fn bitand_assign(&mut self, other: I)
fn bitand_assign(&mut self, other: I)
Takes the inplace intersection of the set with another.
Source§impl<'a, I> BitOr<I> for &'a IdSetwhere
I: IntoBlockIterator,
impl<'a, I> BitOr<I> for &'a IdSetwhere
I: IntoBlockIterator,
Source§impl<I> BitOr<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> BitOr<I> for IdSetwhere
I: IntoBlockIterator,
Source§impl<I> BitOrAssign<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> BitOrAssign<I> for IdSetwhere
I: IntoBlockIterator,
Source§fn bitor_assign(&mut self, other: I)
fn bitor_assign(&mut self, other: I)
Takes the inplace union of the set with another.
Source§impl<'a, I> BitXor<I> for &'a IdSetwhere
I: IntoBlockIterator,
impl<'a, I> BitXor<I> for &'a IdSetwhere
I: IntoBlockIterator,
Source§impl<I> BitXor<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> BitXor<I> for IdSetwhere
I: IntoBlockIterator,
Source§impl<I> BitXorAssign<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> BitXorAssign<I> for IdSetwhere
I: IntoBlockIterator,
Source§fn bitxor_assign(&mut self, other: I)
fn bitxor_assign(&mut self, other: I)
Takes the inplace symmetric difference of the set with another.
Source§impl Extend<usize> for IdSet
impl Extend<usize> for IdSet
Source§fn extend<I: IntoIterator<Item = Id>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Id>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl FromIterator<usize> for IdSet
impl FromIterator<usize> for IdSet
Source§impl<'a> IntoBlockIterator for &'a IdSet
impl<'a> IntoBlockIterator for &'a IdSet
Source§impl IntoBlockIterator for IdSet
impl IntoBlockIterator for IdSet
Source§impl<'a> IntoIterator for &'a IdSet
impl<'a> IntoIterator for &'a IdSet
Source§impl IntoIterator for IdSet
impl IntoIterator for IdSet
Source§impl<'a, I> Sub<I> for &'a IdSetwhere
I: IntoBlockIterator,
impl<'a, I> Sub<I> for &'a IdSetwhere
I: IntoBlockIterator,
Source§impl<I> Sub<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> Sub<I> for IdSetwhere
I: IntoBlockIterator,
Source§impl<I> SubAssign<I> for IdSetwhere
I: IntoBlockIterator,
impl<I> SubAssign<I> for IdSetwhere
I: IntoBlockIterator,
Source§fn sub_assign(&mut self, other: I)
fn sub_assign(&mut self, other: I)
Takes the inplace difference of the set with another.