pub struct IndexSet<T> { /* private fields */ }
Expand description
Implementations§
Source§impl<T> IndexSet<T>
impl<T> IndexSet<T>
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted in the IndexSet
.
Sourcepub fn contains<Q>(&self, value: &Q) -> bool
pub fn contains<Q>(&self, value: &Q) -> bool
Returns true if the IndexSet
contains an element equal to the value
.
Sourcepub fn get<Q>(&self, value: &Q) -> Option<&T>
pub fn get<Q>(&self, value: &Q) -> Option<&T>
Returns a reference to the element in the IndexSet
, if any, that is equal to the value
.
Sourcepub fn get_index_of<Q>(&self, value: &Q) -> Option<usize>
pub fn get_index_of<Q>(&self, value: &Q) -> Option<usize>
Return the index of the item provided, if it exists.
Sourcepub fn insert(&mut self, value: T) -> bool
pub fn insert(&mut self, value: T) -> bool
Adds value
to the IndexSet
.
Returns whether the value was newly inserted:
- Returns
true
if the set did not previously contain an equal value. - Returns
false
otherwise and the entry is not updated.
Sourcepub fn swap_remove<Q>(&mut self, value: &Q) -> bool
pub fn swap_remove<Q>(&mut self, value: &Q) -> bool
Remove the value from the IndexSet
, and return true
if it was present.
Like Vec::swap_remove
, the value is removed by swapping it with the
last element of the set and popping it off. This perturbs
the position of what used to be the last element!
Return false
if value
was not in the set.
Computes in O(1) time (average).
Sourcepub fn replace(&mut self, value: T) -> Option<T>
pub fn replace(&mut self, value: T) -> Option<T>
Adds a value to the IndexSet
, replacing the existing value, if any, that is equal to the given
one. Returns the replaced value.
Sourcepub fn is_disjoint(&self, other: &IndexSet<T>) -> bool
pub fn is_disjoint(&self, other: &IndexSet<T>) -> bool
Returns true
if self
has no elements in common with other
.
This is equivalent to checking for an empty intersection.
Sourcepub fn is_subset(&self, other: &IndexSet<T>) -> bool
pub fn is_subset(&self, other: &IndexSet<T>) -> bool
Returns true
if the IndexSet
is a subset of another,
i.e., other
contains at least all the values in self
.
Sourcepub fn is_superset(&self, other: &IndexSet<T>) -> bool
pub fn is_superset(&self, other: &IndexSet<T>) -> bool
Returns true
if the IndexSet
is a superset of another,
i.e., self
contains at least all the values in other
.
Trait Implementations§
Source§impl<T> Extend<T> for IndexSet<T>
impl<T> Extend<T> for IndexSet<T>
Source§fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = T>,
fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = T>,
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<T> FromIterator<T> for IndexSet<T>
impl<T> FromIterator<T> for IndexSet<T>
Source§impl<'a, T> IntoIterator for &'a IndexSet<T>
impl<'a, T> IntoIterator for &'a IndexSet<T>
Source§impl<T> IntoIterator for IndexSet<T>
impl<T> IntoIterator for IndexSet<T>
impl<T> Eq for IndexSet<T>
Auto Trait Implementations§
impl<T> Freeze for IndexSet<T>
impl<T> RefUnwindSafe for IndexSet<T>where
T: RefUnwindSafe,
impl<T> Send for IndexSet<T>where
T: Send,
impl<T> Sync for IndexSet<T>where
T: Sync,
impl<T> Unpin for IndexSet<T>where
T: Unpin,
impl<T> UnwindSafe for IndexSet<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<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
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more