pub struct SlotMap<T, C: Collector<T> = DefaultCollector> { /* private fields */ }Implementations§
Source§impl<T> SlotMap<T, DefaultCollector>
impl<T> SlotMap<T, DefaultCollector>
pub fn new(max_capacity: u32) -> Self
pub fn with_global(max_capacity: u32, global: GlobalHandle) -> Self
Source§impl<T, C: Collector<T>> SlotMap<T, C>
impl<T, C: Collector<T>> SlotMap<T, C>
pub fn with_collector(max_capacity: u32, collector: C) -> Self
pub fn with_global_and_collector( max_capacity: u32, global: GlobalHandle, collector: C, ) -> Self
pub fn capacity(&self) -> u32
pub fn len(&self) -> u32
pub fn is_empty(&self) -> bool
pub fn global(&self) -> &GlobalHandle
pub fn collector(&self) -> &C
Sourcepub fn insert<'a>(
&'a self,
value: T,
guard: impl Into<Cow<'a, Guard<'a>>>,
) -> SlotId
pub fn insert<'a>( &'a self, value: T, guard: impl Into<Cow<'a, Guard<'a>>>, ) -> SlotId
§Panics
Panics if guard.global() does not equal self.global().
Sourcepub fn insert_with_tag<'a>(
&'a self,
value: T,
tag: u32,
guard: impl Into<Cow<'a, Guard<'a>>>,
) -> SlotId
pub fn insert_with_tag<'a>( &'a self, value: T, tag: u32, guard: impl Into<Cow<'a, Guard<'a>>>, ) -> SlotId
§Panics
- Panics if
guard.global()does not equalself.global(). - Panics if
taghas more than the low 8 bits set.
pub fn insert_mut(&mut self, value: T) -> SlotId
Sourcepub fn insert_with_tag_mut(&mut self, value: T, tag: u32) -> SlotId
pub fn insert_with_tag_mut(&mut self, value: T, tag: u32) -> SlotId
§Panics
Panics if tag has more than the low 8 bits set.
Sourcepub fn remove<'a>(
&'a self,
id: SlotId,
guard: impl Into<Cow<'a, Guard<'a>>>,
) -> Option<Ref<'a, T>>
pub fn remove<'a>( &'a self, id: SlotId, guard: impl Into<Cow<'a, Guard<'a>>>, ) -> Option<Ref<'a, T>>
§Panics
Panics if guard.global() does not equal self.global().
Sourcepub fn try_collect(&self, guard: &Guard<'_>)
pub fn try_collect(&self, guard: &Guard<'_>)
§Panics
Panics if guard.global() does not equal self.global().
pub fn remove_mut(&mut self, id: SlotId) -> Option<T>
Sourcepub fn get<'a>(
&'a self,
id: SlotId,
guard: impl Into<Cow<'a, Guard<'a>>>,
) -> Option<Ref<'a, T>>
pub fn get<'a>( &'a self, id: SlotId, guard: impl Into<Cow<'a, Guard<'a>>>, ) -> Option<Ref<'a, T>>
§Panics
Panics if guard.global() does not equal self.global().
Sourcepub unsafe fn get_unprotected(&self, id: SlotId) -> Option<&T>
pub unsafe fn get_unprotected(&self, id: SlotId) -> Option<&T>
§Safety
You must ensure that the epoch is pinned before you call this method and that the
returned reference doesn’t outlive all epoch::Guards active on the thread, or that all
accesses to self are externally synchronized (for example through the use of a Mutex or
by being single-threaded).
pub fn get_mut(&mut self, id: SlotId) -> Option<&mut T>
pub fn get_many_mut<const N: usize>( &mut self, ids: [SlotId; N], ) -> Option<[&mut T; N]>
Sourcepub fn index<'a>(
&'a self,
index: u32,
guard: impl Into<Cow<'a, Guard<'a>>>,
) -> Option<Ref<'a, T>>
pub fn index<'a>( &'a self, index: u32, guard: impl Into<Cow<'a, Guard<'a>>>, ) -> Option<Ref<'a, T>>
§Panics
Panics if guard.global() does not equal self.global().
Sourcepub unsafe fn index_unprotected(&self, index: u32) -> Option<&T>
pub unsafe fn index_unprotected(&self, index: u32) -> Option<&T>
§Safety
You must ensure that the epoch is pinned before you call this method and that the
returned reference doesn’t outlive all epoch::Guards active on the thread, or that all
accesses to self are externally synchronized (for example through the use of a Mutex or
by being single-threaded).
pub fn index_mut(&mut self, index: u32) -> Option<&mut T>
Sourcepub unsafe fn index_unchecked<'a>(
&'a self,
index: u32,
guard: impl Into<Cow<'a, Guard<'a>>>,
) -> Ref<'a, T>
pub unsafe fn index_unchecked<'a>( &'a self, index: u32, guard: impl Into<Cow<'a, Guard<'a>>>, ) -> Ref<'a, T>
Sourcepub unsafe fn index_unchecked_unprotected(&self, index: u32) -> &T
pub unsafe fn index_unchecked_unprotected(&self, index: u32) -> &T
§Safety
indexmust be in bounds of the slots vector and the slot must have been initialized and must not be free.- You must ensure that the epoch is pinned before you call this method and that the
returned reference doesn’t outlive all
epoch::Guards active on the thread, or that all accesses toselfare externally synchronized (for example through the use of aMutexor by being single-threaded).
Sourcepub unsafe fn index_unchecked_mut(&mut self, index: u32) -> &mut T
pub unsafe fn index_unchecked_mut(&mut self, index: u32) -> &mut T
§Safety
index must be in bounds of the slots vector and the slot must have been initialized and
must not be free.
Sourcepub fn iter<'a>(&'a self, guard: impl Into<Cow<'a, Guard<'a>>>) -> Iter<'a, T> ⓘ
pub fn iter<'a>(&'a self, guard: impl Into<Cow<'a, Guard<'a>>>) -> Iter<'a, T> ⓘ
§Panics
Panics if guard.global() does not equal self.global().
Sourcepub unsafe fn iter_unprotected(&self) -> IterUnprotected<'_, T> ⓘ
pub unsafe fn iter_unprotected(&self) -> IterUnprotected<'_, T> ⓘ
§Safety
You must ensure that the epoch is [pinned] before you call this method and that the
returned reference doesn’t outlive all epoch::Guards active on the thread, or that all
accesses to self are externally synchronized (for example through the use of a Mutex or
by being single-threaded).