#![forbid(unsafe_code)]
use core::borrow::Borrow;
use super::BBTreeMap;
use crate::allocator::Allocator;
use crate::inline_key::InlineKeyStrategy;
impl<K, V, S: InlineKeyStrategy<K>, A: Allocator> BBTreeMap<K, V, S, A> {
#[inline]
pub fn read_many<Q, R, const N: usize>(
&self,
keys: [&Q; N],
f: impl FnMut(&K, &V) -> R,
) -> [Option<R>; N]
where
K: Borrow<Q>,
Q: Ord + ?Sized,
{
self.tree.read_many(keys, f)
}
#[inline]
pub fn get_many_copied<Q, const N: usize>(&self, keys: [&Q; N]) -> [Option<V>; N]
where
K: Borrow<Q>,
Q: Ord + ?Sized,
V: Copy,
{
self.tree.get_many_copied(keys)
}
#[inline]
pub fn insert_many<const N: usize>(&self, entries: [(K, V); N]) -> [Option<V>; N]
where
K: Ord,
{
self.tree.insert_many(entries, &self.alloc)
}
#[inline]
pub fn get_many_cloned<Q, const N: usize>(&self, keys: [&Q; N]) -> [Option<V>; N]
where
K: Borrow<Q>,
Q: Ord + ?Sized,
V: Clone,
{
self.read_many(keys, |_, value| value.clone())
}
}