Struct solana_runtime::accounts_cache::SlotCacheInner [−][src]
pub struct SlotCacheInner { /* fields omitted */ }
Implementations
Methods from Deref<Target = DashMap<Pubkey, CachedAccount>>
Hash a given item to produce a usize. Uses the provided or default HashBuilder.
Allows you to peek at the inner shards that store your data. You should probably not use this unless you know what you are doing.
Requires the raw-api
feature to be enabled.
Examples
use dashmap::DashMap; let map = DashMap::<(), ()>::new(); println!("Amount of shards: {}", map.shards().len());
Finds which shard a certain key is stored in. You should probably not use this unless you know what you are doing. Note that shard selection is dependent on the default or provided HashBuilder.
Requires the raw-api
feature to be enabled.
Examples
use dashmap::DashMap; let map = DashMap::new(); map.insert("coca-cola", 1.4); println!("coca-cola is stored in shard: {}", map.determine_map("coca-cola"));
Finds which shard a certain hash is stored in.
Requires the raw-api
feature to be enabled.
Examples
use dashmap::DashMap; let map: DashMap<i32, i32> = DashMap::new(); let key = "key"; let hash = map.hash_usize(&key); println!("hash is stored in shard: {}", map.determine_shard(hash));
Returns a reference to the map’s BuildHasher
.
Examples
use dashmap::DashMap; use std::collections::hash_map::RandomState; let hasher = RandomState::new(); let map: DashMap<i32, i32> = DashMap::new(); let hasher: &RandomState = map.hasher();
Inserts a key and a value into the map. Returns the old value associated with the key if there was one.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let map = DashMap::new(); map.insert("I am the key!", "And I am the value!");
Removes an entry from the map, returning the key and value if they existed in the map.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let soccer_team = DashMap::new(); soccer_team.insert("Jack", "Goalie"); assert_eq!(soccer_team.remove("Jack").unwrap().1, "Goalie");
Removes an entry from the map, returning the key and value if the entry existed and the provided conditional function returned true.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
use dashmap::DashMap; let soccer_team = DashMap::new(); soccer_team.insert("Sam", "Forward"); soccer_team.remove_if("Sam", |_, position| position == &"Goalie"); assert!(soccer_team.contains_key("Sam"));
use dashmap::DashMap; let soccer_team = DashMap::new(); soccer_team.insert("Sam", "Forward"); soccer_team.remove_if("Sam", |_, position| position == &"Forward"); assert!(!soccer_team.contains_key("Sam"));
Creates an iterator over a DashMap yielding immutable references.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap; let words = DashMap::new(); words.insert("hello", "world"); assert_eq!(words.iter().count(), 1);
Iterator over a DashMap yielding mutable references.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let map = DashMap::new(); map.insert("Johnny", 21); map.iter_mut().for_each(|mut r| *r += 1); assert_eq!(*map.get("Johnny").unwrap(), 22);
Get a immutable reference to an entry in the map
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap; let youtubers = DashMap::new(); youtubers.insert("Bosnian Bill", 457000); assert_eq!(*youtubers.get("Bosnian Bill").unwrap(), 457000);
Get a mutable reference to an entry in the map
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let class = DashMap::new(); class.insert("Albin", 15); *class.get_mut("Albin").unwrap() -= 1; assert_eq!(*class.get("Albin").unwrap(), 14);
Remove excess capacity to reduce memory usage.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Retain elements that whose predicates return true and discard elements whose predicates return false.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let people = DashMap::new(); people.insert("Albin", 15); people.insert("Jones", 22); people.insert("Charlie", 27); people.retain(|_, v| *v > 20); assert_eq!(people.len(), 2);
Fetches the total number of key-value pairs stored in the map.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap; let people = DashMap::new(); people.insert("Albin", 15); people.insert("Jones", 22); people.insert("Charlie", 27); assert_eq!(people.len(), 3);
Checks if the map is empty or not.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap; let map = DashMap::<(), ()>::new(); assert!(map.is_empty());
Removes all key-value pairs in the map.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let stats = DashMap::new(); stats.insert("Goals", 4); assert!(!stats.is_empty()); stats.clear(); assert!(stats.is_empty());
Returns how many key-value pairs the map can store without reallocating.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Modify a specific value according to a function.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let stats = DashMap::new(); stats.insert("Goals", 4); stats.alter("Goals", |_, v| v * 2); assert_eq!(*stats.get("Goals").unwrap(), 8);
Panics
If the given closure panics, then alter
will abort the process
Modify every value in the map according to a function.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap; let stats = DashMap::new(); stats.insert("Wins", 4); stats.insert("Losses", 2); stats.alter_all(|_, v| v + 1); assert_eq!(*stats.get("Wins").unwrap(), 5); assert_eq!(*stats.get("Losses").unwrap(), 3);
Panics
If the given closure panics, then alter_all
will abort the process
Checks if the map contains a specific key.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap; let team_sizes = DashMap::new(); team_sizes.insert("Dakota Cherries", 23); assert!(team_sizes.contains_key("Dakota Cherries"));
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for SlotCacheInner
impl Send for SlotCacheInner
impl Sync for SlotCacheInner
impl Unpin for SlotCacheInner
impl UnwindSafe for SlotCacheInner
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V