rename generic V -> T. Matches intent better. V is now a larger type that contains T (#19798)

This commit is contained in:
Jeff Washington (jwash)
2021-09-12 10:25:09 -05:00
committed by GitHub
parent d2731a2d93
commit 361101bd31

View File

@ -10,31 +10,31 @@ type K = Pubkey;
// one instance of this represents one bin of the accounts index. // one instance of this represents one bin of the accounts index.
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct InMemAccountsIndex<V: IsCached> { pub struct InMemAccountsIndex<T: IsCached> {
// backing store // backing store
map: HashMap<Pubkey, AccountMapEntry<V>>, map: HashMap<Pubkey, AccountMapEntry<T>>,
} }
impl<V: IsCached> InMemAccountsIndex<V> { impl<T: IsCached> InMemAccountsIndex<T> {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
map: HashMap::new(), map: HashMap::new(),
} }
} }
pub fn entry(&mut self, pubkey: Pubkey) -> Entry<K, AccountMapEntry<V>> { pub fn entry(&mut self, pubkey: Pubkey) -> Entry<K, AccountMapEntry<T>> {
self.map.entry(pubkey) self.map.entry(pubkey)
} }
pub fn items(&self) -> Vec<(K, AccountMapEntry<V>)> { pub fn items(&self) -> Vec<(K, AccountMapEntry<T>)> {
self.map.iter().map(|(k, v)| (*k, v.clone())).collect() self.map.iter().map(|(k, v)| (*k, v.clone())).collect()
} }
pub fn keys(&self) -> Keys<K, AccountMapEntry<V>> { pub fn keys(&self) -> Keys<K, AccountMapEntry<T>> {
self.map.keys() self.map.keys()
} }
pub fn get(&self, key: &K) -> Option<AccountMapEntry<V>> { pub fn get(&self, key: &K) -> Option<AccountMapEntry<T>> {
self.map.get(key).cloned() self.map.get(key).cloned()
} }