struct RefMut<'a, K, V> {
indices: &'a mut HashTable<usize>,
entries: &'a mut Vec<Bucket<K, V>>,
}
Expand description
Mutable references to the parts of an IndexMapCore
.
When using HashTable::find_entry
, that takes hold of &mut indices
, so we have to borrow our
&mut entries
separately, and there’s no way to go back to a &mut IndexMapCore
. So this type
is used to implement methods on the split references, and IndexMapCore
can also call those to
avoid duplication.
Fields§
§indices: &'a mut HashTable<usize>
§entries: &'a mut Vec<Bucket<K, V>>
Implementations§
source§impl<'a, K, V> RefMut<'a, K, V>
impl<'a, K, V> RefMut<'a, K, V>
fn new( indices: &'a mut HashTable<usize>, entries: &'a mut Vec<Bucket<K, V>>, ) -> Self
sourcefn reserve_entries(&mut self, additional: usize)
fn reserve_entries(&mut self, additional: usize)
Reserve entries capacity, rounded up to match the indices
sourcefn insert_unique(
self,
hash: HashValue,
key: K,
value: V,
) -> OccupiedEntry<'a, K, V>
fn insert_unique( self, hash: HashValue, key: K, value: V, ) -> OccupiedEntry<'a, K, V>
Insert a key-value pair in entries
,
without checking whether it already exists.
sourcefn shift_insert_unique(
&mut self,
index: usize,
hash: HashValue,
key: K,
value: V,
)
fn shift_insert_unique( &mut self, index: usize, hash: HashValue, key: K, value: V, )
Insert a key-value pair in entries
at a particular index,
without checking whether it already exists.
sourcefn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
Remove an entry by shifting all entries that follow it
sourcefn shift_remove_finish(&mut self, index: usize) -> (K, V)
fn shift_remove_finish(&mut self, index: usize) -> (K, V)
Remove an entry by shifting all entries that follow it
The index should already be removed from self.indices
.
sourcefn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
Remove an entry by swapping it with the last
sourcefn swap_remove_finish(&mut self, index: usize) -> (K, V)
fn swap_remove_finish(&mut self, index: usize) -> (K, V)
Finish removing an entry by swapping it with the last
The index should already be removed from self.indices
.
sourcefn decrement_indices(&mut self, start: usize, end: usize)
fn decrement_indices(&mut self, start: usize, end: usize)
Decrement all indices in the range start..end
.
The index start - 1
should not exist in self.indices
.
All entries should still be in their original positions.
sourcefn increment_indices(&mut self, start: usize, end: usize)
fn increment_indices(&mut self, start: usize, end: usize)
Increment all indices in the range start..end
.
The index end
should not exist in self.indices
.
All entries should still be in their original positions.