pub struct IdentitySet<T, A: Allocator = Global> { /* private fields */ }
Expand description
Implementations§
Source§impl<T> IdentitySet<T>
impl<T> IdentitySet<T>
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Preallocates a new identity set.
§Panics
If [T; cap]
could not be allocated using the global allocator, then this function will panic.
This function will also panic if cap
is greater than isize::MAX
.
Sourcepub unsafe fn from_raw_parts(ptr: *mut T, cap: usize, len: usize) -> Self
pub unsafe fn from_raw_parts(ptr: *mut T, cap: usize, len: usize) -> Self
Source§impl<T, A: Allocator> IdentitySet<T, A>
impl<T, A: Allocator> IdentitySet<T, A>
Sourcepub const fn new_in(alloc: A) -> Self
pub const fn new_in(alloc: A) -> Self
Constructs a new, empty identity set with a specific allocator.
Sourcepub fn with_capacity_in(cap: usize, alloc: A) -> Self
pub fn with_capacity_in(cap: usize, alloc: A) -> Self
Preallocates a new identity set with a specific allocator.
§Panics
If [T; cap]
could not be allocated with the given allocator, then this function will panic.
This function will also panic if cap
is greater than isize::MAX
.
Sourcepub unsafe fn from_raw_parts_in(
ptr: *mut T,
cap: usize,
len: usize,
alloc: A,
) -> Self
pub unsafe fn from_raw_parts_in( ptr: *mut T, cap: usize, len: usize, alloc: A, ) -> Self
Sourcepub fn retain<F: FnMut(&T) -> bool>(&mut self, f: F)
pub fn retain<F: FnMut(&T) -> bool>(&mut self, f: F)
Retains only keys as specified by a predicate.
In other words, each key k
where !f(k)
is true.
§Panics
Panics if f
panics.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the set.
All contained keys are dropped after a call to this method. The length counter is then reset to zero.
Sourcepub fn reserve(&mut self, count: usize)
pub fn reserve(&mut self, count: usize)
Reserves additional capacity for the set.
§Panics
This method will panic if the internal buffer could not be grown.
It will also panic if the new capacity of the set is greater than isize::MAX
.
Sourcepub fn shrink_to(&mut self, cap: usize)
pub fn shrink_to(&mut self, cap: usize)
Shrinks the set to a specified length.
The capacity is shrunk such that it exactly contains the current data.
§Panics
If the provided capacity is greater than the current, then this method will panic.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the set to the current length.
The capacity is shrunk such that it exactly contains the current data.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Retrieves the total capacity of the set.
Remember that this capacity can – if needed to – be increased using the reserve
method.
Sourcepub fn as_ptr(&self) -> *const T
pub fn as_ptr(&self) -> *const T
Gets a pointer to the set buffer.
Note that this pointer may necessarily be dangling if the set isn’t currently in an allocated state.
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Gets a mutable pointer to the set buffer.
Note that this pointer may necessarily be dangling if the set isn’t currently in an allocated state.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Gets a mutable slice over the set’s keys.
Source§impl<T, A> IdentitySet<T, A>
impl<T, A> IdentitySet<T, A>
Sourcepub fn insert(&mut self, key: T) -> bool
pub fn insert(&mut self, key: T) -> bool
Inserts a new key pair into the set.
If the provided key already exists in the set, then this method will return true
.
In all other cases, it will return false
.
§Panics
If the set did not already hold key
as a key and could not grow its buffer to accommodate the key, then this method will panic.
Sourcepub fn take<U>(&mut self, key: &U) -> Option<T>
pub fn take<U>(&mut self, key: &U) -> Option<T>
Takes a specific key out from the set.
If the provided key was not present in the set, then this method will instead return a None
instance.
Sourcepub fn remove(&mut self, key: &T) -> bool
pub fn remove(&mut self, key: &T) -> bool
Remove a specific key from the set.
This method will return true
if the provided key was present in the set.
Sourcepub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T, A> ⓘ
pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T, A> ⓘ
Gets an iterator denoting the intersection between two sets.
Sourcepub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T, A> ⓘ
pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T, A> ⓘ
Gets an iterator denoting the difference between two sets.
Sourcepub fn symmetric_difference<'a>(
&'a self,
other: &'a Self,
) -> SymmetricDifference<'a, T, A> ⓘ
pub fn symmetric_difference<'a>( &'a self, other: &'a Self, ) -> SymmetricDifference<'a, T, A> ⓘ
Gets an iterator denoting the symmetric difference between two sets
Trait Implementations§
Source§impl<T, A> BitAnd for &IdentitySet<T, A>
impl<T, A> BitAnd for &IdentitySet<T, A>
Source§impl<T, A> BitOr for &IdentitySet<T, A>
impl<T, A> BitOr for &IdentitySet<T, A>
Source§impl<T, A> BitXor for &IdentitySet<T, A>
impl<T, A> BitXor for &IdentitySet<T, A>
Source§impl<T: Clone, A: Clone + Allocator> Clone for IdentitySet<T, A>
impl<T: Clone, A: Clone + Allocator> Clone for IdentitySet<T, A>
Source§fn clone(&self) -> IdentitySet<T, A>
fn clone(&self) -> IdentitySet<T, A>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T, A> Debug for IdentitySet<T, A>
impl<T, A> Debug for IdentitySet<T, A>
Source§impl<T, A> Extend<T> for IdentitySet<T, A>
impl<T, A> Extend<T> for IdentitySet<T, A>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&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
)