Struct OnionFastMap

Source
pub struct OnionFastMap<K: PartialEq + Eq + Hash + Clone, V> { /* private fields */ }
Expand description

Onion 高性能稀疏映射。

基于键池索引实现的稀疏键值对存储,支持高效查找与插入。 适用于参数绑定、捕获环境等虚拟机场景。 不保证键的唯一性,后插入的值可能会覆盖先前的值。

§字段

  • pairs: (索引, 值) 对列表
  • pool: 关联的键池

Implementations§

Source§

impl<K: PartialEq + Eq + Hash + Clone, V> OnionFastMap<K, V>

Source

pub fn new(pool: OnionKeyPool<K>) -> Self

Source

pub fn pool(&self) -> &OnionKeyPool<K>

Source

pub fn new_with_pairs(pairs: Vec<(usize, V)>, pool: OnionKeyPool<K>) -> Self

Source

pub fn push<Q>(&mut self, key: &Q, value: V) -> Option<()>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn push_with_index(&mut self, index: usize, value: V) -> Option<()>

Source

pub fn pairs(&self) -> &[(usize, V)]

Source

pub fn set_pairs(&mut self, pairs: Vec<(usize, V)>)

Source

pub fn clear(&mut self)

Source

pub fn to_index<Q>(&self, key: &Q) -> Option<usize>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn from_index(&self, index: usize) -> Option<&K>

Source

pub fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn get_by_index(&self, target_index: usize) -> Option<&V>

Trait Implementations§

Source§

impl<K: Clone + PartialEq + Eq + Hash + Clone, V: Clone> Clone for OnionFastMap<K, V>

Source§

fn clone(&self) -> OnionFastMap<K, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug + PartialEq + Eq + Hash + Clone, V: Debug> Debug for OnionFastMap<K, V>

Source§

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

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

impl<K: PartialEq + Eq + Hash + Clone, V> Default for OnionFastMap<K, V>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<K, V> Freeze for OnionFastMap<K, V>

§

impl<K, V> RefUnwindSafe for OnionFastMap<K, V>

§

impl<K, V> Send for OnionFastMap<K, V>
where K: Sync + Send, V: Send,

§

impl<K, V> Sync for OnionFastMap<K, V>
where K: Sync + Send, V: Sync,

§

impl<K, V> Unpin for OnionFastMap<K, V>
where V: Unpin,

§

impl<K, V> UnwindSafe for OnionFastMap<K, V>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.