Struct IdSet

Source
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

Source

pub fn new() -> Self

Creates an empty IdSet.

Source

pub fn new_filled(n: usize) -> Self

Creates a IdSet filled with all elements from 0 to n.

Source

pub fn with_capacity(n: usize) -> Self

Creates a empty IdSet that can hold elements up to n before reallocating.

Source

pub fn len(&self) -> usize

Returns the number of distinct elements in the set.

Source

pub fn is_empty(&self) -> bool

Returns true if the set is empty.

Source

pub fn capacity(&self) -> usize

Returns capacity of the set. Inserting any elements less than this will not cause reallocation.

Source

pub fn reserve(&mut self, cap: usize)

Resizes the set such that capacity() >= cap.

Source

pub fn shrink_to_fit(&mut self)

Resizes the set to minimise allocated memory.

Source

pub fn clear(&mut self)

Removes all elements from the set.

Source

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.

Source

pub fn remove(&mut self, id: Id) -> bool

Removes the given element from the set, returning true if it was in the set.

Source

pub fn contains(&self, id: Id) -> bool

Returns true if the given element is in the set.

Source

pub fn retain<F: FnMut(Id) -> bool>(&mut self, pred: F)

Remove all elements that don’t satisfy the predicate.

Source

pub fn as_blocks(&self) -> &[Block]

Returns the underlying blocks as a slice.

Source

pub fn iter(&self) -> Iter<'_>

An iterator over all elements in increasing order.

Source

pub fn blocks(&self) -> Blocks<'_>

Returns an iterator over the blocks of the underlying representation.

Source

pub fn into_blocks(self) -> IntoBlocks

Returns a consuming iterator over the blocks of the underlying representation.

Source

pub fn union<I>(&self, other: I) -> BlockIter<Union<Blocks<'_>, I::Blocks>>

Takes the union of the set with another. Equivalent to self | other.

Source

pub fn intersection<I>( &self, other: I, ) -> BlockIter<Intersection<Blocks<'_>, I::Blocks>>

Takes the intersection of the set with another. Equivalent to self & other.

Source

pub fn difference<I>( &self, other: I, ) -> BlockIter<Difference<Blocks<'_>, I::Blocks>>

Takes the difference of the set with another. Equivalent to self - other.

Source

pub fn symmetric_difference<I>( &self, other: I, ) -> BlockIter<SymmetricDifference<Blocks<'_>, I::Blocks>>

Takes the symmetric difference of the set with another. Equivalent to self ^ other.

Source

pub fn into_union<I>(self, other: I) -> BlockIter<Union<IntoBlocks, I::Blocks>>

Consumes the set and takes the union with another.

Source

pub fn into_intersection<I>( self, other: I, ) -> BlockIter<Intersection<IntoBlocks, I::Blocks>>

Consumes the set and takes the intersection with another.

Source

pub fn into_difference<I>( self, other: I, ) -> BlockIter<Difference<IntoBlocks, I::Blocks>>

Consumes the set and takes the difference with another.

Source

pub fn into_symmetric_difference<I>( self, other: I, ) -> BlockIter<SymmetricDifference<IntoBlocks, I::Blocks>>

Consumes the set and takes the symmetric difference with another.

Source

pub fn inplace_union<I>(&mut self, other: I)

Take the union of the set inplace with another set. Equivalent to *self |= other.

Source

pub fn inplace_intersection<I>(&mut self, other: I)

Take the intersection of the set inplace with another set. Equivalent to *self &= other.

Source

pub fn inplace_difference<I>(&mut self, other: I)

Take the difference of the set inplace with another set. Equivalent to *self -= other.

Source

pub fn inplace_symmetric_difference<I>(&mut self, other: I)

Take the symmetric difference of the set inplace with another set. Equivalent to *self ^= other.

Source

pub fn is_disjoint(&self, other: &Self) -> bool

Returns true if the sets are disjoint.

Source

pub fn is_superset(&self, other: &Self) -> bool

Returns true if self is a superset of other.

Source

pub fn is_subset(&self, other: &Self) -> bool

Returns true if self is a subset of other.

Trait Implementations§

Source§

impl<'a, I> BitAnd<I> for &'a IdSet

Source§

fn bitand(self, other: I) -> Self::Output

Takes the intersection of two objects.

Source§

type Output = BlockIter<Intersection<Iter<'a>, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the & operator.
Source§

impl<I> BitAnd<I> for IdSet

Source§

fn bitand(self, other: I) -> Self::Output

Takes the intersection of two objects.

Source§

type Output = BlockIter<Intersection<IntoIter, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the & operator.
Source§

impl<I> BitAndAssign<I> for IdSet

Source§

fn bitand_assign(&mut self, other: I)

Takes the inplace intersection of the set with another.

Source§

impl<'a, I> BitOr<I> for &'a IdSet

Source§

fn bitor(self, other: I) -> Self::Output

Takes the union of two objects.

Source§

type Output = BlockIter<Union<Iter<'a>, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the | operator.
Source§

impl<I> BitOr<I> for IdSet

Source§

fn bitor(self, other: I) -> Self::Output

Takes the union of two objects.

Source§

type Output = BlockIter<Union<IntoIter, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the | operator.
Source§

impl<I> BitOrAssign<I> for IdSet

Source§

fn bitor_assign(&mut self, other: I)

Takes the inplace union of the set with another.

Source§

impl<'a, I> BitXor<I> for &'a IdSet

Source§

fn bitxor(self, other: I) -> Self::Output

Takes the symmetric difference of two objects.

Source§

type Output = BlockIter<SymmetricDifference<Iter<'a>, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the ^ operator.
Source§

impl<I> BitXor<I> for IdSet

Source§

fn bitxor(self, other: I) -> Self::Output

Takes the symmetric difference of two objects.

Source§

type Output = BlockIter<SymmetricDifference<IntoIter, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the ^ operator.
Source§

impl<I> BitXorAssign<I> for IdSet

Source§

fn bitxor_assign(&mut self, other: I)

Takes the inplace symmetric difference of the set with another.

Source§

impl Clone for IdSet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IdSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IdSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Extend<usize> for IdSet

Source§

fn extend<I: IntoIterator<Item = Id>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FromIterator<usize> for IdSet

Source§

fn from_iter<I: IntoIterator<Item = Id>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a> IntoBlockIterator for &'a IdSet

Source§

type Blocks = Iter<'a>

The raw iterator type.
Source§

fn into_block_iter(self) -> BlockIter<Self::Blocks>

Creates a block iterator.
Source§

impl IntoBlockIterator for IdSet

Source§

type Blocks = IntoIter

The raw iterator type.
Source§

fn into_block_iter(self) -> BlockIter<Self::Blocks>

Creates a block iterator.
Source§

impl<'a> IntoIterator for &'a IdSet

Source§

type Item = usize

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for IdSet

Source§

type Item = usize

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for IdSet

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, I> Sub<I> for &'a IdSet

Source§

fn sub(self, other: I) -> Self::Output

Takes the difference of two objects.

Source§

type Output = BlockIter<Difference<Iter<'a>, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the - operator.
Source§

impl<I> Sub<I> for IdSet

Source§

fn sub(self, other: I) -> Self::Output

Takes the difference of two objects.

Source§

type Output = BlockIter<Difference<IntoIter, <I as IntoBlockIterator>::Blocks>>

The resulting type after applying the - operator.
Source§

impl<I> SubAssign<I> for IdSet

Source§

fn sub_assign(&mut self, other: I)

Takes the inplace difference of the set with another.

Source§

impl Eq for IdSet

Auto Trait Implementations§

§

impl Freeze for IdSet

§

impl RefUnwindSafe for IdSet

§

impl Send for IdSet

§

impl Sync for IdSet

§

impl Unpin for IdSet

§

impl UnwindSafe for IdSet

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.