pub struct ScatteredMap<K: 'static, V: 'static> { /* private fields */ }Expand description
A swiss-table-style lookup table initialized with link-time data. Each item in the map must have a unique hash.
For a flat list in arbitrary link order, use crate::ScatteredSlice. For a sorted
list without per-item handles, use crate::ScatteredSortedSlice. For static
handles at scatter sites, use crate::ScatteredReferencedSlice; when sorted order
is required as well, use crate::ScatteredSortedReferencedSlice.
§Performance notes
The map’s metadata section is only ever written to once, and then becomes read-only. This means that we can avoid tombstone logic.
Metadata is arranged in 16-slot SIMD groups for optimal performance.
//! Example for `ScatteredMap`.
use scattered_collect::{gather, map::ScatteredMap, scatter};
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd)]
struct MyId(u32);
#[gather]
static MAP: ScatteredMap<&'static str, MyId>;
#[scatter(MAP)]
static APPLE: (&'static str, MyId) = ("apple", MyId(1));
#[scatter(MAP)]
static BANANA: (&'static str, MyId) = ("banana", MyId(2));
#[scatter(MAP)]
static ORANGE: (&'static str, MyId) = ("orange", MyId(3));
fn main() {
println!("APPLE: {:?}", APPLE);
println!("BANANA: {:?}", BANANA);
println!("ORANGE: {:?}", ORANGE);
println!("Entries:");
for (key, value) in &MAP {
println!(" - {}: {:?}", key, value);
}
}Implementations§
Source§impl<K: ConstHash + PartialEq + 'static, V: 'static> ScatteredMap<K, V>
impl<K: ConstHash + PartialEq + 'static, V: 'static> ScatteredMap<K, V>
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
True when a key is present in the map.
Trait Implementations§
Source§impl<K: 'static, V: 'static> IntoIterator for &'static ScatteredMap<K, V>
impl<K: 'static, V: 'static> IntoIterator for &'static ScatteredMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for ScatteredMap<K, V>
impl<K, V> RefUnwindSafe for ScatteredMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for ScatteredMap<K, V>
impl<K, V> Sync for ScatteredMap<K, V>
impl<K, V> Unpin for ScatteredMap<K, V>
impl<K, V> UnsafeUnpin for ScatteredMap<K, V>
impl<K, V> UnwindSafe for ScatteredMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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