pub use nullvec::prelude::Slicer;
pub trait IndexerIndex: Slicer {
type Key;
fn contains(&self, label: &Self::Key) -> bool;
fn push(&mut self, label: Self::Key);
fn get_loc(&self, label: &Self::Key) -> usize;
fn get_locs(&self, labels: &[Self::Key]) -> Vec<usize>;
fn init_state(&self);
}
pub trait RowIndex<'s>: Sized {
type Key;
type Row;
fn len(&'s self) -> usize;
fn head(&'s self, n: usize) -> Self {
let indexer: Vec<usize> = (0..n).collect();
self.ilocs(&indexer)
}
fn tail(&'s self, n: usize) -> Self {
let len = self.len();
let indexer: Vec<usize> = ((len - n)..len).collect();
self.ilocs(&indexer)
}
fn reindex<'l>(&'s self, labels: &'l [Self::Key]) -> Self;
fn reindex_by_index<'l>(&'s self, locations: &'l [usize]) -> Self;
fn loc<'l>(&'s self, label: &'l Self::Key) -> Self::Row;
fn iloc<'l>(&'s self, location: &'l usize) -> Self::Row;
fn locs<'l>(&'s self, labels: &'l [Self::Key]) -> Self {
self.reindex(labels)
}
fn ilocs<'l>(&'s self, locations: &'l [usize]) -> Self {
self.reindex_by_index(locations)
}
fn blocs<'l>(&'s self, flags: &'l [bool]) -> Self;
}
pub trait ColIndex<'s>: Sized {
type Key;
type Column;
fn get<'l>(&'s self, label: &'l Self::Key) -> Self::Column;
fn iget<'l>(&'s self, label: &'l usize) -> Self::Column;
fn gets<'l>(&'s self, labels: &'l [Self::Key]) -> Self;
fn igets<'l>(&'s self, locations: &'l [usize]) -> Self;
}
pub trait Append<'s>: Sized {
fn append<'o>(&'s self, other: &'o Self) -> Self;
}
pub trait Concatenation<'s>: Sized {
fn concat<'o>(&'s self, other: &'o Self) -> Self;
}
pub trait Join: Sized {
fn join_inner(&self, other: &Self) -> Self;
}
pub trait Apply<'s, R> {
type In;
type FOut;
type Out;
fn apply<'f>(&'s self, func: &'f Fn(&Self::In) -> Self::FOut) -> Self::Out;
}
pub trait BasicAggregation<'s> {
type Kept;
type Counted;
fn sum(&'s self) -> Self::Kept;
fn count(&'s self) -> Self::Counted;
}
pub trait NumericAggregation<'s> {
type Coerced;
fn mean(&'s self) -> Self::Coerced;
fn var(&'s self) -> Self::Coerced;
fn unbiased_var(&'s self) -> Self::Coerced;
fn std(&'s self) -> Self::Coerced;
fn unbiased_std(&'s self) -> Self::Coerced;
}
pub trait ComparisonAggregation<'s> {
type Kept;
fn min(&'s self) -> Self::Kept;
fn max(&'s self) -> Self::Kept;
}
pub trait Description<'s>
: BasicAggregation<'s> + NumericAggregation<'s> + ComparisonAggregation<'s> {
type Described;
fn describe(&'s self) -> Self::Described;
}