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
use std::collections::VecDeque;

/// Return a sample from the dataset at a given index.
pub trait GetSample {
    /// Type of one sample of the dataset.
    type Sample: Sized;
    /// Return the dataset sample corresponding to the index.
    fn get_sample(&self, index: usize) -> Self::Sample;
}

impl<T: Clone> GetSample for Vec<T> {
    type Sample = T;
    fn get_sample(&self, index: usize) -> Self::Sample {
        self[index].clone()
    }
}

impl<T: Clone> GetSample for VecDeque<T> {
    type Sample = T;
    fn get_sample(&self, index: usize) -> Self::Sample {
        self[index].clone()
    }
}

// TODO: `GetSample` for Array?