Skip to main content

Arena

Struct Arena 

Source
pub struct Arena<K: Key, V> { /* private fields */ }
Expand description

阶段 1 直接复用 slotmap,后续如需自定义 generational index 再替换。

Implementations§

Source§

impl<K: Key, V> Arena<K, V>

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, value: V) -> K

Source

pub fn get(&self, id: K) -> Option<&V>

Source

pub fn get_mut(&mut self, id: K) -> Option<&mut V>

Source

pub fn remove(&mut self, id: K) -> Option<V>

Source

pub fn contains(&self, id: K) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter(&self) -> impl Iterator<Item = (K, &V)>

迭代所有 (key, value) 对(测试 / 调试用)

Trait Implementations§

Source§

impl<K: Key, V> Default for Arena<K, V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K, V> Forget for Arena<K, V>

§

impl<K, V> Freeze for Arena<K, V>
where *const u8 is !null: Freeze, PhantomData<Slot<V>>: Freeze, PhantomData<fn(K) -> K>: Freeze,

§

impl<K, V> Move for Arena<K, V>

§

impl<K, V> RefUnwindSafe for Arena<K, V>
where V: RefUnwindSafe,

§

impl<K, V> Send for Arena<K, V>
where V: Send, RawVecInner: Send,

§

impl<K, V> Sync for Arena<K, V>
where V: Sync, RawVecInner: Sync,

§

impl<K, V> Unpin for Arena<K, V>
where V: Unpin, *const u8 is !null: Unpin,

§

impl<K, V> UnsafeUnpin for Arena<K, V>
where *const u8 is !null: UnsafeUnpin, PhantomData<Slot<V>>: UnsafeUnpin, PhantomData<fn(K) -> K>: UnsafeUnpin,

§

impl<K, V> UnwindSafe for Arena<K, V>
where RawVecInner: UnwindSafe, V: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.