pub struct Arena<T: ?Sized, Storage = T> { /* private fields */ }Expand description
Implementations§
Source§impl<T: ?Sized, Storage> Arena<T, Storage>
impl<T: ?Sized, Storage> Arena<T, Storage>
Sourcepub fn retain(&self, filter: impl Fn(Interned<T, Storage>) -> bool) -> Mapping
pub fn retain(&self, filter: impl Fn(Interned<T, Storage>) -> bool) -> Mapping
Returns a mapping to build an arena containing only the items of this arena that satisfy the given predicate.
Sourcepub fn retain_values(
&self,
values: impl Iterator<Item = Interned<T, Storage>>,
) -> Mapping
Available on crate feature retain only.
pub fn retain_values( &self, values: impl Iterator<Item = Interned<T, Storage>>, ) -> Mapping
retain only.Returns a mapping to build an arena containing only the given items.
See also retain_builder() if you need a more
flexible way of adding items to retain.
Sourcepub fn retain_builder(&self) -> RetainBuilder<T, Storage>
Available on crate feature retain only.
pub fn retain_builder(&self) -> RetainBuilder<T, Storage>
retain only.Returns a builder allowing to select items to retain, and create an arena containing only these.
Source§impl<T, Storage> Arena<T, Storage>
impl<T, Storage> Arena<T, Storage>
Sourcepub fn map(&self, mapping: &ReverseMapping) -> Self
pub fn map(&self, mapping: &ReverseMapping) -> Self
Returns a re-ordered version of this arena based on the given mapping.
Sourcepub fn map2(&self, mapping: &ReverseMapping, f: impl Fn(&T) -> Storage) -> Self
pub fn map2(&self, mapping: &ReverseMapping, f: impl Fn(&T) -> Storage) -> Self
Returns a re-ordered version of this arena based on the given mapping,
where each item is additionally transformed according to the given
function f.
The transformation function should be injective, i.e. different inputs should map to different outputs. Otherwise a value may appear twice in the resulting arena
Source§impl<T: ?Sized, Storage> Arena<T, Storage>
impl<T: ?Sized, Storage> Arena<T, Storage>
Sourcepub fn with_capacity(len: usize) -> Self
pub fn with_capacity(len: usize) -> Self
Creates a new arena with pre-allocated space to store at least len
values of type T.
Source§impl<T: ?Sized, Storage> Arena<T, Storage>where
Storage: Borrow<T>,
impl<T: ?Sized, Storage> Arena<T, Storage>where
Storage: Borrow<T>,
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = &T>
Available on crate feature raw only.
pub fn iter(&self) -> impl ExactSizeIterator<Item = &T>
raw only.Returns an iterator over all items in this arena, in indexing order.
Note that because Arena is a concurrent data structure, this is only
a snapshot. Once this iterator has been created, for performance reasons
it will not iterate over items added afterwards, even on the same
thread.
Source§impl<T, Storage> Arena<T, Storage>
impl<T, Storage> Arena<T, Storage>
Sourcepub fn find(&self, value: &T) -> Option<Interned<T, Storage>>
pub fn find(&self, value: &T) -> Option<Interned<T, Storage>>
Returns the given value’s Interned handle if it is already interned.
Otherwise, this simply returns None without adding the value to this
arena.
See also find_mut(), which is more efficient if you
hold a mutable reference to this arena as it avoids acquiring locks.
Source§impl<T, Storage> Arena<T, Storage>
impl<T, Storage> Arena<T, Storage>
Sourcepub fn push_mut(&mut self, value: Storage) -> u32
Available on crate feature raw only.
pub fn push_mut(&mut self, value: Storage) -> u32
raw only.Unconditionally push a value, without validating that it’s already interned.
Calling this function multiple times with the same value doesn’t violate safety, but the value will be stored multiple times in the arena.
Source§impl<T: ?Sized, Storage> Arena<T, Storage>where
Storage: GetSize,
impl<T: ?Sized, Storage> Arena<T, Storage>where
Storage: GetSize,
Sourcepub fn print_summary(&self, prefix: &str, title: &str, total_bytes: usize)
Available on crate features debug and std only.
pub fn print_summary(&self, prefix: &str, title: &str, total_bytes: usize)
debug and std only.Prints a summary of the storage used by this arena to stdout.
Source§impl<T: ?Sized, Storage> Arena<T, Storage>
impl<T: ?Sized, Storage> Arena<T, Storage>
Sourcepub fn references(&self) -> usize
Available on crate feature debug only.
pub fn references(&self) -> usize
debug only.Returns the total number of references to items in this arena.
The underlying counter is incremented each time a value is interned, whether it was already previously in the arena or not.
Source§impl<T, Storage> Arena<T, Storage>
impl<T, Storage> Arena<T, Storage>
Sourcepub fn intern(
&self,
value: impl Borrow<T> + Into<Storage>,
) -> Interned<T, Storage>
Available on crate feature sync only.
pub fn intern( &self, value: impl Borrow<T> + Into<Storage>, ) -> Interned<T, Storage>
sync only.Interns the given value in this arena.
If the value was already interned in this arena, it will simply be borrowed to retrieve its interning index. Otherwise it will then be converted to store it into the arena.
See also intern_mut(), which is more efficient if
you hold a mutable reference to this arena as it avoids acquiring locks.
Sourcepub fn intern_mut(
&mut self,
value: impl Borrow<T> + Into<Storage>,
) -> Interned<T, Storage>
pub fn intern_mut( &mut self, value: impl Borrow<T> + Into<Storage>, ) -> Interned<T, Storage>
Interns the given value in this arena.
If the value was already interned in this arena, it will simply be borrowed to retrieve its interning index. Otherwise it will then be converted to store it into the arena.
Contrary to intern(), no locks are held internally
because this function already takes an exclusive mutable reference to
this arena.
Source§impl<T: ?Sized, Storage> Arena<T, Storage>where
Storage: Clone,
impl<T: ?Sized, Storage> Arena<T, Storage>where
Storage: Clone,
Sourcepub fn lookup(&self, interned: Interned<T, Storage>) -> Storage
pub fn lookup(&self, interned: Interned<T, Storage>) -> Storage
Retrieves the given Interned value from this arena.
The caller is responsible for ensuring that the same arena was used to intern this value, otherwise an arbitrary value will be returned or a panic will happen.
See also lookup_ref() if you only need a
reference.
Trait Implementations§
Source§impl<'de, T, Storage> Deserialize<'de> for Arena<T, Storage>
Available on crate feature serde only.
impl<'de, T, Storage> Deserialize<'de> for Arena<T, Storage>
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl<T, Storage> Eq for Arena<T, Storage>
Source§impl<T: ?Sized, Storage> GetSize for Arena<T, Storage>where
Storage: GetSize,
Available on crate feature get-size2 only.
impl<T: ?Sized, Storage> GetSize for Arena<T, Storage>where
Storage: GetSize,
get-size2 only.Source§fn get_heap_size_with_tracker<Tr: GetSizeTracker>(
&self,
tracker: Tr,
) -> (usize, Tr)
fn get_heap_size_with_tracker<Tr: GetSizeTracker>( &self, tracker: Tr, ) -> (usize, Tr)
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreAuto Trait Implementations§
impl<T, Storage = T> !Freeze for Arena<T, Storage>
impl<T, Storage = T> !RefUnwindSafe for Arena<T, Storage>
impl<T, Storage> Send for Arena<T, Storage>
impl<T, Storage> Sync for Arena<T, Storage>
impl<T, Storage> Unpin for Arena<T, Storage>where
T: ?Sized,
impl<T, Storage> UnsafeUnpin for Arena<T, Storage>where
T: ?Sized,
impl<T, Storage> UnwindSafe for Arena<T, Storage>where
Storage: RefUnwindSafe,
T: ?Sized,
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.