Struct SlotMap

Source
pub struct SlotMap<T, C: Collector<T> = DefaultCollector> { /* private fields */ }

Implementations§

Source§

impl<T> SlotMap<T, DefaultCollector>

Source

pub fn new(max_capacity: u32) -> Self

Source

pub fn with_global(max_capacity: u32, global: GlobalHandle) -> Self

Source§

impl<T, C: Collector<T>> SlotMap<T, C>

Source

pub fn with_collector(max_capacity: u32, collector: C) -> Self

Source

pub fn with_global_and_collector( max_capacity: u32, global: GlobalHandle, collector: C, ) -> Self

Source

pub fn capacity(&self) -> u32

Source

pub fn len(&self) -> u32

Source

pub fn is_empty(&self) -> bool

Source

pub fn global(&self) -> &GlobalHandle

Source

pub fn collector(&self) -> &C

Source

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().

Source

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 equal self.global().
  • Panics if tag has more than the low 8 bits set.
Source

pub fn insert_mut(&mut self, value: T) -> SlotId

Source

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.

Source

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().

Source

pub fn try_collect(&self, guard: &Guard<'_>)

§Panics

Panics if guard.global() does not equal self.global().

Source

pub fn remove_mut(&mut self, id: SlotId) -> Option<T>

Source

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().

Source

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).

Source

pub fn get_mut(&mut self, id: SlotId) -> Option<&mut T>

Source

pub fn get_many_mut<const N: usize>( &mut self, ids: [SlotId; N], ) -> Option<[&mut T; N]>

Source

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().

Source

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).

Source

pub fn index_mut(&mut self, index: u32) -> Option<&mut T>

Source

pub unsafe fn index_unchecked<'a>( &'a self, index: u32, guard: impl Into<Cow<'a, Guard<'a>>>, ) -> Ref<'a, T>

§Safety

index must be in bounds of the slots vector and the slot must have been initialized and must not be free.

§Panics

Panics if guard.global() does not equal self.global().

Source

pub unsafe fn index_unchecked_unprotected(&self, index: u32) -> &T

§Safety
  • index must 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 to self are externally synchronized (for example through the use of a Mutex or by being single-threaded).
Source

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.

Source

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().

Source

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).

Source

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

Trait Implementations§

Source§

impl<T: Debug, C: Collector<T>> Debug for SlotMap<T, C>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, C: Collector<T>> Drop for SlotMap<T, C>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, T, C: Collector<T>> IntoIterator for &'a mut SlotMap<T, C>

Source§

type Item = (SlotId, &'a mut T)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, C: Collector<T>> RefUnwindSafe for SlotMap<T, C>

Source§

impl<T, C: Collector<T>> UnwindSafe for SlotMap<T, C>

Auto Trait Implementations§

§

impl<T, C = DefaultCollector> !Freeze for SlotMap<T, C>

§

impl<T, C> Send for SlotMap<T, C>
where C: Send, T: Send,

§

impl<T, C> Sync for SlotMap<T, C>
where C: Sync, T: Sync,

§

impl<T, C> Unpin for SlotMap<T, C>
where C: Unpin, T: Unpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.