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>
impl<T: IntegerId> DirectIdSet<T>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new DirectIdSet with no elements.
Sourcepub fn with_capacity(max_id: usize) -> Self
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.
Sourcepub fn insert(&mut self, value: T) -> bool
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.
Sourcepub fn remove(&mut self, value: impl EquivalentId<T>) -> bool
pub fn remove(&mut self, value: impl EquivalentId<T>) -> bool
Remove the specified value from the set, returning whether it was previously present.
Sourcepub fn contains(&self, value: impl EquivalentId<T>) -> bool
pub fn contains(&self, value: impl EquivalentId<T>) -> bool
Check if this set contains the specified value
Sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter(&self) -> Iter<'_, T> ⓘ
Iterate over the values in this set.
Guaranteed to be ordered by the integer value of the key.
Sourcepub fn len(&self) -> usize
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
Trait Implementations§
Source§impl<T: Clone + IntegerId> Clone for DirectIdSet<T>
impl<T: Clone + IntegerId> Clone for DirectIdSet<T>
Source§fn clone(&self) -> DirectIdSet<T>
fn clone(&self) -> DirectIdSet<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: IntegerId> Debug for DirectIdSet<T>
impl<T: IntegerId> Debug for DirectIdSet<T>
Source§impl<T: IntegerId> Default for DirectIdSet<T>
impl<T: IntegerId> Default for DirectIdSet<T>
Source§impl<'de, T> Deserialize<'de> for DirectIdSet<T>where
T: IntegerId + Deserialize<'de>,
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>
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>
impl<'a, T: IntegerId> Extend<&'a T> for DirectIdSet<T>
Source§fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I)
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)
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)
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>
impl<T: IntegerId> Extend<T> for DirectIdSet<T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
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)
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)
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>
impl<'a, T: IntegerId> FromIterator<&'a T> for DirectIdSet<T>
Source§impl<T: IntegerId> FromIterator<T> for DirectIdSet<T>
impl<T: IntegerId> FromIterator<T> for DirectIdSet<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<T: IntegerId> Index<T> for DirectIdSet<T>
impl<T: IntegerId> Index<T> for DirectIdSet<T>
Source§impl<'a, T: IntegerId + 'a> IntoIterator for &'a DirectIdSet<T>
impl<'a, T: IntegerId + 'a> IntoIterator for &'a DirectIdSet<T>
Source§impl<T: IntegerId> IntoIterator for DirectIdSet<T>
impl<T: IntegerId> IntoIterator for DirectIdSet<T>
Source§impl<T: IntegerId + Ord> Ord for DirectIdSet<T>
impl<T: IntegerId + Ord> Ord for DirectIdSet<T>
Source§fn cmp(&self, other: &DirectIdSet<T>) -> Ordering
fn cmp(&self, other: &DirectIdSet<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: IntegerId> PartialEq for DirectIdSet<T>
impl<T: IntegerId> PartialEq for DirectIdSet<T>
Source§impl<T: IntegerId + PartialOrd> PartialOrd for DirectIdSet<T>
impl<T: IntegerId + PartialOrd> PartialOrd for DirectIdSet<T>
Source§impl<T> Serialize for DirectIdSet<T>
impl<T> Serialize for DirectIdSet<T>
Source§impl<T: IntegerId> VisitMap<T> for DirectIdSet<T>
impl<T: IntegerId> VisitMap<T> for DirectIdSet<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.