use alloc::vec::Vec;
use crate::ReadPermit;
use super::BrandedVec;
impl<'brand, T> BrandedVec<'brand, T> {
#[inline]
pub fn partition_for_each_mut_with<F>(&mut self, plan: crate::sync::PartitionPlan, f: F)
where
T: Send,
F: Fn(usize, &mut [T]) + Sync,
{
crate::sync::partition_for_each_with(&mut self.cells, plan, |start, mut shard| {
f(start, shard.as_mut_slice());
});
}
#[inline]
pub fn partition_map_mut_with<R, F>(&mut self, plan: crate::sync::PartitionPlan, f: F) -> Vec<R>
where
T: Send,
R: Send,
F: Fn(usize, &mut [T]) -> R + Sync,
{
crate::sync::partition_map_with(&mut self.cells, plan, |start, mut shard| {
f(start, shard.as_mut_slice())
})
}
#[inline]
pub fn partition_map_with<'a, P, R, F>(
&'a self,
permit: P,
plan: crate::sync::PartitionPlan,
f: F,
) -> Vec<R>
where
P: ReadPermit<'brand> + 'a,
T: Sync,
R: Send,
F: Fn(usize, &[T]) -> R + Sync,
{
crate::sync::partition_read_map_with(self.as_slice(permit), plan, f)
}
#[inline]
pub fn partition_for_each_with<'a, P, F>(
&'a self,
permit: P,
plan: crate::sync::PartitionPlan,
f: F,
) where
P: ReadPermit<'brand> + 'a,
T: Sync,
F: Fn(usize, &[T]) + Sync,
{
crate::sync::partition_read_for_each_with(self.as_slice(permit), plan, f);
}
}