Struct rustc_ap_rustc_data_structures::sorted_map::SortedIndexMultiMap[][src]

pub struct SortedIndexMultiMap<I: Idx, K, V> { /* fields omitted */ }
Expand description

An indexed multi-map that preserves insertion order while permitting both O(log n) lookup of an item by key and O(1) lookup by index.

This data structure is a hybrid of an IndexVec and a SortedMap. Like IndexVec, SortedIndexMultiMap assigns a typed index to each item while preserving insertion order. Like SortedMap, SortedIndexMultiMap has efficient lookup of items by key. However, this is accomplished by sorting an array of item indices instead of the items themselves.

Unlike SortedMap, this data structure can hold multiple equivalent items at once, so the get_by_key method and its variants return an iterator instead of an Option. Equivalent items will be yielded in insertion order.

Unlike a general-purpose map like BTreeSet or HashSet, SortedMap and SortedIndexMultiMap require O(n) time to insert a single item. This is because we may need to insert into the middle of the sorted array. Users should avoid mutating this data structure in-place.

Implementations

impl<I: Idx, K: Ord, V> SortedIndexMultiMap<I, K, V>[src]

pub fn new() -> Self[src]

pub fn len(&self) -> usize[src]

pub fn is_empty(&self) -> bool[src]

pub fn into_iter(self) -> impl DoubleEndedIterator<Item = (K, V)>[src]

Returns an iterator over the items in the map in insertion order.

pub fn into_iter_enumerated(
    self
) -> impl DoubleEndedIterator<Item = (I, (K, V))>
[src]

Returns an iterator over the items in the map in insertion order along with their indices.

pub fn iter(&self) -> impl '_ + DoubleEndedIterator<Item = (&K, &V)>[src]

Returns an iterator over the items in the map in insertion order.

pub fn iter_enumerated(
    &self
) -> impl '_ + DoubleEndedIterator<Item = (I, (&K, &V))>
[src]

Returns an iterator over the items in the map in insertion order along with their indices.

pub fn get(&self, idx: I) -> Option<&(K, V)>[src]

Returns the item in the map with the given index.

pub fn get_by_key<Q: 'a + ?Sized, 'a>(
    &'a self,
    key: &Q
) -> impl 'a + Iterator<Item = &'a V> where
    Q: Ord,
    K: Borrow<Q>, 
[src]

Returns an iterator over the items in the map that are equal to key.

If there are multiple items that are equivalent to key, they will be yielded in insertion order.

pub fn get_by_key_enumerated<Q: ?Sized>(
    &self,
    key: &Q
) -> impl '_ + Iterator<Item = (I, &V)> where
    Q: Ord,
    K: Borrow<Q>, 
[src]

Returns an iterator over the items in the map that are equal to key along with their indices.

If there are multiple items that are equivalent to key, they will be yielded in insertion order.

Trait Implementations

impl<I: Clone + Idx, K: Clone, V: Clone> Clone for SortedIndexMultiMap<I, K, V>[src]

fn clone(&self) -> SortedIndexMultiMap<I, K, V>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<I: Debug + Idx, K: Debug, V: Debug> Debug for SortedIndexMultiMap<I, K, V>[src]

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

Formats the value using the given formatter. Read more

impl<I: Idx, K: Ord, V> FromIterator<(K, V)> for SortedIndexMultiMap<I, K, V>[src]

fn from_iter<J>(iter: J) -> Self where
    J: IntoIterator<Item = (K, V)>, 
[src]

Creates a value from an iterator. Read more

impl<I: Idx, K, V> Hash for SortedIndexMultiMap<I, K, V> where
    K: Hash,
    V: Hash
[src]

fn hash<H: Hasher>(&self, hasher: &mut H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<I: Idx, K, V, C> HashStable<C> for SortedIndexMultiMap<I, K, V> where
    K: HashStable<C>,
    V: HashStable<C>, 
[src]

fn hash_stable(&self, ctx: &mut C, hasher: &mut StableHasher)[src]

impl<I: Idx, K, V> Index<I> for SortedIndexMultiMap<I, K, V>[src]

type Output = V

The returned type after indexing.

fn index(&self, idx: I) -> &Self::Output[src]

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

impl<I: Idx, K: PartialEq, V: PartialEq> PartialEq<SortedIndexMultiMap<I, K, V>> for SortedIndexMultiMap<I, K, V>[src]

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

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<I: Idx, K: Eq, V: Eq> Eq for SortedIndexMultiMap<I, K, V>[src]

Auto Trait Implementations

impl<I, K, V> RefUnwindSafe for SortedIndexMultiMap<I, K, V> where
    I: RefUnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<I, K, V> Send for SortedIndexMultiMap<I, K, V> where
    I: Send,
    K: Send,
    V: Send

impl<I, K, V> Sync for SortedIndexMultiMap<I, K, V> where
    I: Sync,
    K: Sync,
    V: Sync

impl<I, K, V> Unpin for SortedIndexMultiMap<I, K, V> where
    I: Unpin,
    K: Unpin,
    V: Unpin

impl<I, K, V> UnwindSafe for SortedIndexMultiMap<I, K, V> where
    I: UnwindSafe,
    K: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]