[][src]Struct pui_arena::base::sparse::Arena

pub struct Arena<T, I = (), V: Version = DefaultVersion> { /* fields omitted */ }

A sparse arena

Implementations

impl<T> Arena<T>[src]

pub const fn new() -> Self[src]

Create a new arena

impl<T, V: Version> Arena<T, (), V>[src]

pub const INIT: Self[src]

An empty arena

pub fn clear(&mut self)[src]

Clear the arena without reducing it's capacity

impl<T, I, V: Version> Arena<T, I, V>[src]

pub fn with_ident(ident: I) -> Self[src]

Create a new arena with the given identifier

pub fn ident(&self) -> &I[src]

Get the associated identifier for this arena

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

Returns true if the arena is empty

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

Returns the number of elements in this arena

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

Returns the capacity of this arena

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

Reserves capacity for at least additional more elements to be inserted in the given collection. The collection may reserve more space to avoid frequent reallocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.

pub fn reserve_exact(&mut self, additional: usize)[src]

Reserves the minimum capacity for exactly additional more elements to be inserted in the given collection. After calling reserve_exact, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore, capacity can not be relied upon to be precisely minimal. Prefer reserve if future insertions are expected.

pub fn parse_key<K: BuildArenaKey<I, V>>(&self, index: usize) -> Option<K>[src]

Check if an index is in bounds, and if it is return a Key<_, _> to it

pub fn vacant_entry(&mut self) -> VacantEntry<'_, T, I, V>[src]

Return a handle to a vacant entry allowing for further manipulation.

This function is useful when creating values that must contain their key. The returned VacantEntry reserves a slot in the arena and is able to query the associated key.

pub fn insert<K: BuildArenaKey<I, V>>(&mut self, value: T) -> K[src]

Insert a value in the arena, returning key assigned to the value.

The returned key can later be used to retrieve or remove the value using indexed lookup and remove. Additional capacity is allocated if needed.

pub fn contains<K: ArenaKey<I, V>>(&self, key: K) -> bool[src]

Return true if a value is associated with the given key.

pub fn remove<K: ArenaKey<I, V>>(&mut self, key: K) -> T[src]

Remove and return the value associated with the given key.

The key is then released and may be associated with future stored values, if the versioning strategy allows it.

Panics if key is not associated with a value.

pub fn try_remove<K: ArenaKey<I, V>>(&mut self, key: K) -> Option<T>[src]

Remove and return the value associated with the given key.

The key is then released and may be associated with future stored values, if the versioning strategy allows it.

Returns None if key is not associated with a value.

pub fn delete<K: ArenaKey<I, V>>(&mut self, key: K) -> bool[src]

Removes the value associated with the given key.

The key is then released and may be associated with future stored values, if the versioning strategy allows it.

Returns true if the value was removed, an false otherwise

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

Return a shared reference to the value associated with the given key.

If the given key is not associated with a value, then None is returned.

pub fn get_mut<K: ArenaKey<I, V>>(&mut self, key: K) -> Option<&mut T>[src]

Return a unique reference to the value associated with the given key.

If the given key is not associated with a value, then None is returned.

pub unsafe fn get_unchecked(&self, index: usize) -> &T[src]

Return a shared reference to the value associated with the given key without performing bounds checking, or checks if there is a value associated to the key

Safety

contains should return true with the given index.

pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T[src]

Return a unique reference to the value associated with the given key without performing bounds checking, or checks if there is a value associated to the key

Safety

contains should return true with the given index.

pub fn delete_all(&mut self)[src]

Deletes all elements from the arena

pub fn retain<F: FnMut(&mut T) -> bool>(&mut self, mut f: F)[src]

Retain only the elements specified by the predicate.

If the predicate returns for a given element true, then the element is kept in the arena.

pub fn keys<K: BuildArenaKey<I, V>>(&self) -> Keys<'_, T, I, V, K>

Notable traits for Keys<'a, T, I, V, K>

impl<'a, T, I, V: Version, K: BuildArenaKey<I, V>> Iterator for Keys<'a, T, I, V, K> type Item = K;
[src]

An iterator over the keys of the arena, in no particular order

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

Notable traits for Iter<'a, T, V>

impl<'a, T, V: Version> Iterator for Iter<'a, T, V> type Item = &'a T;
[src]

An iterator of shared references to values of the arena, in no particular order

pub fn iter_mut(&mut self) -> IterMut<'_, T, V>

Notable traits for IterMut<'a, T, V>

impl<'a, T, V: Version> Iterator for IterMut<'a, T, V> type Item = &'a mut T;
[src]

An iterator of unique references to values of the arena, in no particular order

pub fn drain(&mut self) -> Drain<'_, T, V>

Notable traits for Drain<'a, T, V>

impl<'a, T, V: Version> Iterator for Drain<'a, T, V> type Item = T;
[src]

Return a draining iterator that removes all elements from the arena and yields the removed items.

Note: Elements are removed even if the iterator is only partially consumed or not consumed at all.

pub fn drain_filter<F: FnMut(&mut T) -> bool>(
    &mut self,
    filter: F
) -> DrainFilter<'_, T, V, F>

Notable traits for DrainFilter<'a, T, V, F>

impl<'a, T, V: Version, F: FnMut(&mut T) -> bool> Iterator for DrainFilter<'a, T, V, F> type Item = T;
[src]

Return a draining iterator that removes all elements specified by the predicate from the arena and yields the removed items.

If the predicate returns true for a given element, then it is removed from the arena, and yielded from the iterator.

Note: Elements are removed even if the iterator is only partially consumed or not consumed at all.

pub fn entries<K: BuildArenaKey<I, V>>(&self) -> Entries<'_, T, I, V, K>

Notable traits for Entries<'a, T, I, V, K>

impl<'a, T, I, V: Version, K: BuildArenaKey<I, V>> Iterator for Entries<'a, T, I, V, K> type Item = (K, &'a T);
[src]

An iterator of keys and shared references to values of the arena, in no particular order, with each key being associated to the corrosponding value

pub fn entries_mut<K: BuildArenaKey<I, V>>(
    &mut self
) -> EntriesMut<'_, T, I, V, K>

Notable traits for EntriesMut<'a, T, I, V, K>

impl<'a, T, I, V: Version, K: BuildArenaKey<I, V>> Iterator for EntriesMut<'a, T, I, V, K> type Item = (K, &'a mut T);
[src]

An iterator of keys and unique references to values of the arena, in no particular order, with each key being associated to the corrosponding value

pub fn into_entries<K: BuildArenaKey<I, V>>(self) -> IntoEntries<T, I, V, K>

Notable traits for IntoEntries<T, I, V, K>

impl<'a, T, I, V: Version, K: BuildArenaKey<I, V>> Iterator for IntoEntries<T, I, V, K> type Item = (K, T);
[src]

An iterator of keys and values of the arena, in no particular order, with each key being associated to the corrosponding value

Trait Implementations

impl<T: Clone, I: Clone, V: Clone + Version> Clone for Arena<T, I, V>[src]

impl<T: Debug, I: Debug, V: Debug + Version> Debug for Arena<T, I, V>[src]

impl<T> Default for Arena<T>[src]

impl<T, I, V: Version> Extend<T> for Arena<T, I, V>[src]

impl<T, I, V: Version, K: ArenaKey<I, V>> Index<K> for Arena<T, I, V>[src]

type Output = T

The returned type after indexing.

impl<T, I, V: Version, K: ArenaKey<I, V>> IndexMut<K> for Arena<T, I, V>[src]

impl<T, I, V: Version> IntoIterator for Arena<T, I, V>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T, V>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<T, I, V> Send for Arena<T, I, V> where
    I: Send,
    T: Send,
    V: Send
[src]

impl<T, I, V> Sync for Arena<T, I, V> where
    I: Sync,
    T: Sync,
    V: Sync
[src]

impl<T, I, V> Unpin for Arena<T, I, V> where
    I: Unpin,
    T: Unpin,
    V: Unpin
[src]

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.