use crate::RealType;
use ndarray::{Array2, ArrayView2};
pub trait ParticleContainerAccessor {
type FloatingPointType: RealType;
fn sources(&self) -> ArrayView2<Self::FloatingPointType>;
fn targets(&self) -> ArrayView2<Self::FloatingPointType>;
}
pub struct ParticleContainer<T: RealType> {
sources: Array2<T>,
targets: Array2<T>,
}
pub fn make_particle_container_owned<T: RealType>(
sources: Array2<T>,
targets: Array2<T>,
) -> ParticleContainer<T> {
ParticleContainer { sources, targets }
}
pub fn make_particle_container<'a, T: RealType>(
sources: ArrayView2<'a, T>,
targets: ArrayView2<'a, T>,
) -> ParticleContainerView<'a, T> {
ParticleContainerView { sources, targets }
}
pub struct ParticleContainerView<'a, T: RealType> {
sources: ArrayView2<'a, T>,
targets: ArrayView2<'a, T>,
}
impl<T: RealType> ParticleContainerAccessor for ParticleContainer<T> {
type FloatingPointType = T;
fn sources(&self) -> ArrayView2<Self::FloatingPointType> {
self.sources.view()
}
fn targets(&self) -> ArrayView2<Self::FloatingPointType> {
self.targets.view()
}
}
impl<'a, T: RealType> ParticleContainerAccessor for ParticleContainerView<'a, T> {
type FloatingPointType = T;
fn sources(&self) -> ArrayView2<Self::FloatingPointType> {
self.sources.view()
}
fn targets(&self) -> ArrayView2<Self::FloatingPointType> {
self.targets.view()
}
}