pub struct ArenaSlice<T> { /* private fields */ }Expand description
Interning arena for slices of type T.
Implementations§
Source§impl<T> ArenaSlice<T>
impl<T> ArenaSlice<T>
Sourcepub fn with_capacity(slices: usize, items: usize) -> Self
pub fn with_capacity(slices: usize, items: usize) -> Self
Creates a new arena with pre-allocated space to store at least the given
number of slices, totalling the given number of items of type T.
Sourcepub fn slices(&self) -> usize
pub fn slices(&self) -> usize
Returns the number of slices in this arena.
Note that because ArenaSlice is a concurrent data structure, this is
only a snapshot as viewed by this thread, and the result may change
if other threads are inserting values.
Sourcepub fn items(&self) -> usize
pub fn items(&self) -> usize
Returns the total number of items of type T in this arena.
Note that because ArenaSlice is a concurrent data structure, this is
only a snapshot as viewed by this thread, and the result may change
if other threads are inserting values.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if this arena is empty.
Note that because ArenaSlice is a concurrent data structure, this is
only a snapshot as viewed by this thread, and the result may change
if other threads are inserting values.
Source§impl<T> ArenaSlice<T>
impl<T> ArenaSlice<T>
Sourcepub fn find(&self, value: &[T]) -> Option<InternedSlice<T>>
pub fn find(&self, value: &[T]) -> Option<InternedSlice<T>>
Returns the given value’s InternedSlice handle if it is already
interned.
Otherwise, this simply returns None without adding the value to this
arena.
Source§impl<T> ArenaSlice<T>where
T: GetSize,
impl<T> ArenaSlice<T>where
T: GetSize,
Sourcepub fn print_summary(&self, prefix: &str, title: &str, total_bytes: usize)
Available on crate feature debug only.
pub fn print_summary(&self, prefix: &str, title: &str, total_bytes: usize)
debug only.Prints a summary of the storage used by this arena to stdout.
Source§impl<T> ArenaSlice<T>
impl<T> ArenaSlice<T>
Sourcepub fn intern_owned(&self, value: Vec<T>) -> InternedSlice<T>
pub fn intern_owned(&self, value: Vec<T>) -> InternedSlice<T>
Interns the given value in this arena.
If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.
Sourcepub fn intern_array<const N: usize>(&self, value: [T; N]) -> InternedSlice<T>
pub fn intern_array<const N: usize>(&self, value: [T; N]) -> InternedSlice<T>
Interns the given value in this arena.
If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.
Sourcepub fn push_owned_mut(&mut self, value: Vec<T>) -> InternedSlice<T>
Available on crate feature raw only.
pub fn push_owned_mut(&mut self, value: Vec<T>) -> InternedSlice<T>
raw only.Unconditionally push a value, without validating that it’s already interned.
Sourcepub fn push_array_mut<const N: usize>(
&mut self,
value: [T; N],
) -> InternedSlice<T>
Available on crate feature raw only.
pub fn push_array_mut<const N: usize>( &mut self, value: [T; N], ) -> InternedSlice<T>
raw only.Unconditionally push a value, without validating that it’s already interned.
Source§impl<T> ArenaSlice<T>
impl<T> ArenaSlice<T>
Sourcepub fn intern(&self, value: &[T]) -> InternedSlice<T>
pub fn intern(&self, value: &[T]) -> InternedSlice<T>
Interns the given value in this arena.
If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.
If T is Copy, it may be more efficient to call
intern_copy() instead.
Source§impl<T> ArenaSlice<T>
impl<T> ArenaSlice<T>
Sourcepub fn intern_copy(&self, value: &[T]) -> InternedSlice<T>
pub fn intern_copy(&self, value: &[T]) -> InternedSlice<T>
Interns the given value in this arena.
If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.
If T is only Clone, you can call intern()
instead. If T is also not Clone, you can call
intern_owned() or
intern_array().
Sourcepub fn push_copy_mut(&mut self, value: &[T]) -> u32
Available on crate feature raw only.
pub fn push_copy_mut(&mut self, value: &[T]) -> u32
raw only.Unconditionally push a value, without validating that it’s already interned.
If T is only Clone, you can call push_mut()
instead.
Source§impl<T> ArenaSlice<T>
impl<T> ArenaSlice<T>
Sourcepub fn lookup(&self, interned: InternedSlice<T>) -> &[T]
pub fn lookup(&self, interned: InternedSlice<T>) -> &[T]
Retrieves the given InternedSlice 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.
Trait Implementations§
Source§impl<T> Clone for ArenaSlice<T>
impl<T> Clone for ArenaSlice<T>
Source§impl<T> Debug for ArenaSlice<T>where
T: Debug,
impl<T> Debug for ArenaSlice<T>where
T: Debug,
Source§impl<T> Default for ArenaSlice<T>
impl<T> Default for ArenaSlice<T>
Source§impl<'de, T> Deserialize<'de> for ArenaSlice<T>
Available on crate feature serde only.
impl<'de, T> Deserialize<'de> for ArenaSlice<T>
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>,
Source§impl<T> GetSize for ArenaSlice<T>where
T: GetSize,
Available on crate feature get-size2 only.
impl<T> GetSize for ArenaSlice<T>where
T: 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 moreSource§impl<T> PartialEq for ArenaSlice<T>
impl<T> PartialEq for ArenaSlice<T>
Source§impl<T> Serialize for ArenaSlice<T>where
T: Serialize,
Available on crate feature serde only.
impl<T> Serialize for ArenaSlice<T>where
T: Serialize,
serde only.impl<T> Eq for ArenaSlice<T>
Auto Trait Implementations§
impl<T> !Freeze for ArenaSlice<T>
impl<T> !RefUnwindSafe for ArenaSlice<T>
impl<T> Send for ArenaSlice<T>
impl<T> Sync for ArenaSlice<T>
impl<T> Unpin for ArenaSlice<T>
impl<T> UnsafeUnpin for ArenaSlice<T>
impl<T> UnwindSafe for ArenaSlice<T>where
T: RefUnwindSafe,
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,
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.