DirectIdSet

Struct DirectIdSet 

Source
pub struct DirectIdSet<T: IntegerId> { /* private fields */ }
Expand description

A set whose members implement IntegerId.

This is implemented as a bitset, so memory is proportional to the highest integer index.

Implementations§

Source§

impl<T: IntegerId> DirectIdSet<T>

Source

pub const fn new() -> Self

Create a new DirectIdSet with no elements.

Source

pub fn with_capacity(max_id: usize) -> Self

Initialize the set with the given capacity

Since this is a direct set, this hints at the maximum valid id and not the length.

Source

pub fn insert(&mut self, value: T) -> bool

Inserts the specified element into the set, returning true if it was already in the set and false if it wasn’t.

Source

pub fn remove(&mut self, value: impl EquivalentId<T>) -> bool

Remove the specified value from the set, returning whether it was previously present.

Source

pub fn contains(&self, value: impl EquivalentId<T>) -> bool

Check if this set contains the specified value

Source

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

Iterate over the values in this set.

Guaranteed to be ordered by the integer value of the key.

Source

pub fn clear(&mut self)

Clear the values in this set

Source

pub fn len(&self) -> usize

The number of entries in this set

An DirectIdSet internally tracks this length, so this is a O(1) operation

Source

pub fn is_empty(&self) -> bool

If this set is empty

Source

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

Retain values in the set if the specified closure returns true

Otherwise, they are removed

Trait Implementations§

Source§

impl<T: Clone + IntegerId> Clone for DirectIdSet<T>

Source§

fn clone(&self) -> DirectIdSet<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: IntegerId> Debug for DirectIdSet<T>

Source§

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

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

impl<T: IntegerId> Default for DirectIdSet<T>

Source§

fn default() -> Self

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

impl<'de, T> Deserialize<'de> for DirectIdSet<T>
where T: IntegerId + Deserialize<'de>,

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a, T: IntegerId> Extend<&'a T> for DirectIdSet<T>

Source§

fn extend<I: IntoIterator<Item = &'a T>>(&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<T: IntegerId> Extend<T> for DirectIdSet<T>

Source§

fn extend<I: IntoIterator<Item = T>>(&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<'a, T: IntegerId> FromIterator<&'a T> for DirectIdSet<T>

Source§

fn from_iter<I: IntoIterator<Item = &'a T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: IntegerId> FromIterator<T> for DirectIdSet<T>

Source§

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

Creates a value from an iterator. Read more
Source§

impl<T: IntegerId + Hash> Hash for DirectIdSet<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, T: IntegerId + 'a> Index<&'a T> for DirectIdSet<T>

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, index: &'a T) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: IntegerId> Index<T> for DirectIdSet<T>

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, index: T) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T: IntegerId + 'a> IntoIterator for &'a DirectIdSet<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

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<T: IntegerId> IntoIterator for DirectIdSet<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

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<T: IntegerId + Ord> Ord for DirectIdSet<T>

Source§

fn cmp(&self, other: &DirectIdSet<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: IntegerId> PartialEq for DirectIdSet<T>

Source§

fn eq(&self, other: &DirectIdSet<T>) -> 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<T: IntegerId + PartialOrd> PartialOrd for DirectIdSet<T>

Source§

fn partial_cmp(&self, other: &DirectIdSet<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Serialize for DirectIdSet<T>
where T: IntegerId + Serialize,

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: IntegerId> VisitMap<T> for DirectIdSet<T>

Source§

fn visit(&mut self, a: T) -> bool

Mark a as visited. Read more
Source§

fn is_visited(&self, value: &T) -> bool

Return whether a has been visited before.
Source§

fn unvisit(&mut self, a: T) -> bool

Mark a as unvisited. Read more
Source§

impl<T: IntegerId> Eq for DirectIdSet<T>

Auto Trait Implementations§

§

impl<T> Freeze for DirectIdSet<T>

§

impl<T> RefUnwindSafe for DirectIdSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for DirectIdSet<T>
where T: Send,

§

impl<T> Sync for DirectIdSet<T>
where T: Sync,

§

impl<T> Unpin for DirectIdSet<T>
where T: Unpin,

§

impl<T> UnwindSafe for DirectIdSet<T>
where T: UnwindSafe,

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,