Struct wasmparser::collections::index_set::IndexSet

source ·
pub struct IndexSet<T> { /* private fields */ }
Expand description

A default set of values.

Provides an API compatible with both IndexSet and a custom implementation based on BTreeMap.

Implementations§

source§

impl<T> IndexSet<T>

source

pub fn clear(&mut self)

Clears the IndexSet, removing all elements.

source

pub fn len(&self) -> usize

Returns the number of elements in the IndexSet.

source

pub fn is_empty(&self) -> bool

Returns true if the IndexSet contains no elements.

source

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

Returns an iterator that yields the items in the IndexSet.

source§

impl<T> IndexSet<T>
where T: Eq + Hash + Ord + Clone,

source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more elements to be inserted in the IndexSet.

source

pub fn contains<Q>(&self, value: &Q) -> bool
where T: Borrow<Q>, Q: Hash + Eq + Ord + ?Sized,

Returns true if the IndexSet contains an element equal to the value.

source

pub fn get<Q>(&self, value: &Q) -> Option<&T>
where T: Borrow<Q>, Q: Hash + Eq + Ord + ?Sized,

Returns a reference to the element in the IndexSet, if any, that is equal to the value.

source

pub fn get_index_of<Q>(&self, value: &Q) -> Option<usize>
where T: Borrow<Q>, Q: Hash + Eq + Ord + ?Sized,

Return the index of the item provided, if it exists.

source

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.
source

pub fn swap_remove<Q>(&mut self, value: &Q) -> bool
where T: Borrow<Q>, Q: Hash + Eq + Ord + ?Sized,

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).

source

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.

source

pub fn is_disjoint(&self, other: &Self) -> bool

Returns true if self has no elements in common with other. This is equivalent to checking for an empty intersection.

source

pub fn is_subset(&self, other: &Self) -> bool

Returns true if the IndexSet is a subset of another, i.e., other contains at least all the values in self.

source

pub fn is_superset(&self, other: &Self) -> 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: Clone> Clone for IndexSet<T>

source§

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

Returns a copy 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: Debug> Debug for IndexSet<T>

source§

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

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

impl<T> Default for IndexSet<T>

source§

fn default() -> Self

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

impl<T> Extend<T> for IndexSet<T>
where T: Hash + Eq + Ord + Clone,

source§

fn extend<Iter: IntoIterator<Item = T>>(&mut self, iter: Iter)

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> FromIterator<T> for IndexSet<T>
where T: Hash + Eq + Ord + Clone,

source§

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

Creates a value from an iterator. Read more
source§

impl<T> Index<usize> for IndexSet<T>
where T: Hash + Eq + Ord,

source§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &T

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

impl<'a, T> IntoIterator for &'a IndexSet<T>

source§

type Item = &'a 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> IntoIterator for IndexSet<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> PartialEq for IndexSet<T>
where T: PartialEq + Hash + Ord,

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &Self) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Eq for IndexSet<T>
where T: Eq + Hash + Ord,

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> 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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

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

source§

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

Checks if this value is equivalent to the given key. Read more
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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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

Checks if this value is equivalent to the given key. Read more
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.