1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use core::marker::PhantomData;

use necsim_core::{
    cogs::{Backup, Habitat, LineageStore, MathsCore},
    lineage::{GlobalLineageReference, Lineage},
};

#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[cfg_attr(feature = "cuda", cuda(free = "M", free = "H"))]
pub struct IndependentLineageStore<M: MathsCore, H: Habitat<M>> {
    marker: PhantomData<(M, H)>,
}

impl<M: MathsCore, H: Habitat<M>> Default for IndependentLineageStore<M, H> {
    fn default() -> Self {
        Self {
            marker: PhantomData::<(M, H)>,
        }
    }
}

#[contract_trait]
impl<M: MathsCore, H: Habitat<M>> Backup for IndependentLineageStore<M, H> {
    unsafe fn backup_unchecked(&self) -> Self {
        Self {
            marker: PhantomData::<(M, H)>,
        }
    }
}

#[contract_trait]
impl<M: MathsCore, H: Habitat<M>> LineageStore<M, H> for IndependentLineageStore<M, H> {
    type LocalLineageReference = GlobalLineageReference;

    fn with_capacity(_habitat: &H, _capacity: usize) -> Self {
        Self::default()
    }

    #[must_use]
    fn get_lineage_for_local_reference(
        &self,
        _reference: &GlobalLineageReference,
    ) -> Option<&Lineage> {
        None
    }
}