dsalgo 0.2.6

A package for Datastructures and Algorithms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// Fn(&S, &S) -> S is a trait.
/// this is a dynamic size object at compilation time.
/// thus, it's needed to be enclosed with Box<dyn>
/// pointer.
pub struct Monoid<'a, S> {
    pub operate: &'a dyn Fn(&S, &S) -> S,
    pub identity: &'a dyn Fn() -> S,
    pub commutative: bool,
    pub idempotent: bool,
}

pub struct Semigroup<'a, S> {
    pub operate: &'a dyn Fn(&S, &S) -> S,
    pub commutative: bool,
    pub idempotent: bool,
}