pub struct ArrayMap<K, V, const N: usize>{ /* private fields */ }Expand description
A generic tinyvec::ArrayVec backed map with O(n) lookup. Maintains insertion order and tracks the last updated entry index.
Implementations§
Source§impl<K, V, const N: usize> ArrayMap<K, V, N>
impl<K, V, const N: usize> ArrayMap<K, V, N>
pub fn new() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn last_updated_index(&self) -> Option<usize>
pub fn get(&self, index: usize) -> Option<&(K, V)>
pub fn get_mut(&mut self, index: usize) -> Option<&mut (K, V)>
pub fn get_u8(&self, index: u8) -> Option<&(K, V)>
pub fn get_mut_u8(&mut self, index: u8) -> Option<&mut (K, V)>
pub fn get_by_key(&self, key: &K) -> Option<&V>
pub fn get_mut_by_key(&mut self, key: &K) -> Option<&mut V>
pub fn find(&self, key: &K) -> Option<(usize, &(K, V))>
pub fn find_mut(&mut self, key: &K) -> Option<(usize, &mut (K, V))>
pub fn find_index(&self, key: &K) -> Option<usize>
pub fn set_last_updated_index<E>(&mut self, index: usize) -> Result<(), E>where
E: From<ArrayMapError>,
pub fn insert<E>(&mut self, key: K, value: V, error: E) -> Result<usize, E>
Source§impl<V, const N: usize> ArrayMap<[u8; 32], V, N>where
V: Default,
impl<V, const N: usize> ArrayMap<[u8; 32], V, N>where
V: Default,
pub fn get_by_pubkey(&self, key: &[u8; 32]) -> Option<&V>
pub fn get_mut_by_pubkey(&mut self, key: &[u8; 32]) -> Option<&mut V>
pub fn find_by_pubkey(&self, key: &[u8; 32]) -> Option<(usize, &([u8; 32], V))>
pub fn find_mut_by_pubkey( &mut self, key: &[u8; 32], ) -> Option<(usize, &mut ([u8; 32], V))>
pub fn find_pubkey_index(&self, key: &[u8; 32]) -> Option<usize>
Trait Implementations§
Auto Trait Implementations§
impl<K, V, const N: usize> Freeze for ArrayMap<K, V, N>
impl<K, V, const N: usize> RefUnwindSafe for ArrayMap<K, V, N>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, const N: usize> Send for ArrayMap<K, V, N>
impl<K, V, const N: usize> Sync for ArrayMap<K, V, N>
impl<K, V, const N: usize> Unpin for ArrayMap<K, V, N>
impl<K, V, const N: usize> UnwindSafe for ArrayMap<K, V, N>where
K: UnwindSafe,
V: UnwindSafe,
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
Mutably borrows from an owned value. Read more