mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-31 12:00:42 +00:00
utils: add a few VecMap utility functions
This commit is contained in:
@@ -20,10 +20,22 @@ impl<K: Ord, V> VecMap<K, V> {
|
||||
self.0.is_empty()
|
||||
}
|
||||
|
||||
pub fn last(&self) -> Option<&(K, V)> {
|
||||
self.0.last()
|
||||
}
|
||||
|
||||
pub fn as_slice(&self) -> &[(K, V)] {
|
||||
self.0.as_slice()
|
||||
}
|
||||
|
||||
pub fn inner(self) -> Vec<(K, V)> {
|
||||
self.0
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
self.0.len()
|
||||
}
|
||||
|
||||
/// This function may panic if given a range where the lower bound is
|
||||
/// greater than the upper bound.
|
||||
pub fn slice_range<R: RangeBounds<K>>(&self, range: R) -> &[(K, V)] {
|
||||
@@ -90,6 +102,10 @@ impl<K: Ord, V> VecMap<K, V> {
|
||||
Ok((None, delta_size))
|
||||
}
|
||||
|
||||
pub fn truncate(&mut self, pos: usize) {
|
||||
self.0.truncate(pos)
|
||||
}
|
||||
|
||||
/// Split the map into two.
|
||||
///
|
||||
/// The left map contains everything before `cutoff` (exclusive).
|
||||
|
||||
Reference in New Issue
Block a user