Struct starlark::collections::SmallSet
source · [−]pub struct SmallSet<T>(_);
Expand description
An memory-efficient set with determinstic order, based on SmallMap
.
Implementations
sourceimpl<T> SmallSet<T>
impl<T> SmallSet<T>
sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Empty small set with preallocated capacity.
sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = &T> + Clone
pub fn iter(&self) -> impl ExactSizeIterator<Item = &T> + Clone
Iterate the element references.
sourcepub fn into_iter(self) -> impl ExactSizeIterator<Item = T>
pub fn into_iter(self) -> impl ExactSizeIterator<Item = T>
Convert the set into the iterator over the elements.
sourcepub fn insert(&mut self, key: T) -> bool where
T: Hash + Eq,
pub fn insert(&mut self, key: T) -> bool where
T: Hash + Eq,
Insert the element into the set.
Return true
iff the element was inserted.
sourcepub fn get<Q>(&self, value: &Q) -> Option<&T> where
Q: Hash + Equivalent<T> + ?Sized,
T: Eq,
pub fn get<Q>(&self, value: &Q) -> Option<&T> where
Q: Hash + Equivalent<T> + ?Sized,
T: Eq,
Return a reference to the value stored in the set, if it is present,
else None
.
Computes in O(1) time (average).
sourcepub fn get_index_of<Q>(&self, value: &Q) -> Option<usize> where
Q: Hash + Equivalent<T> + ?Sized,
T: Eq,
pub fn get_index_of<Q>(&self, value: &Q) -> Option<usize> where
Q: Hash + Equivalent<T> + ?Sized,
T: Eq,
Return item index, if it exists in the set
sourcepub fn remove<Q>(&mut self, key: &Q) where
Q: ?Sized + Hash + Equivalent<T>,
T: Eq,
pub fn remove<Q>(&mut self, key: &Q) where
Q: ?Sized + Hash + Equivalent<T>,
T: Eq,
Remove the element from the set if it is present.
sourcepub fn take<Q>(&mut self, key: &Q) -> Option<T> where
Q: ?Sized + Hash + Equivalent<T>,
T: Eq,
pub fn take<Q>(&mut self, key: &Q) -> Option<T> where
Q: ?Sized + Hash + Equivalent<T>,
T: Eq,
Remove the element from the set if it is present,
and return the removed element.
Trait Implementations
sourceimpl<T> FromIterator<T> for SmallSet<T> where
T: Hash + Eq,
impl<T> FromIterator<T> for SmallSet<T> where
T: Hash + Eq,
sourcefn 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
sourceimpl<T> Ord for SmallSet<T> where
T: Ord,
impl<T> Ord for SmallSet<T> where
T: Ord,
sourceimpl<T> PartialOrd<SmallSet<T>> for SmallSet<T> where
T: PartialOrd + Eq,
impl<T> PartialOrd<SmallSet<T>> for SmallSet<T> where
T: PartialOrd + Eq,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T> Eq for SmallSet<T> where
T: Eq,
Auto Trait Implementations
impl<T> RefUnwindSafe for SmallSet<T> where
T: RefUnwindSafe,
impl<T> Send for SmallSet<T> where
T: Send,
impl<T> Sync for SmallSet<T> where
T: Sync,
impl<T> Unpin for SmallSet<T> where
T: Unpin,
impl<T> UnwindSafe for SmallSet<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> AsARef<T> for T where
T: ?Sized,
impl<T> AsARef<T> for T where
T: ?Sized,
sourcefn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
fn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more