Trait nekolib::traits::binop::Magma

source ·
pub trait Magma {
    type Set: Eq;

    // Required method
    fn op(&self, x: Self::Set, y: Self::Set) -> Self::Set;
}
Expand description

マグマ。

集合 $M$ と二項演算 $\circ$ のペア $(M, \circ)$ であり、次の性質を満たす。 $$ x, y \in M \implies x \circ y \in M. $$

Examples

use nekolib::traits::Magma;
use nekolib::utils::OpMin;

let op_min = OpMin::default();
assert_eq!(3, op_min.op(3, 4));

Required Associated Types§

source

type Set: Eq

集合 $M$ に対応する型。

Required Methods§

source

fn op(&self, x: Self::Set, y: Self::Set) -> Self::Set

$x \circ y$ を返す。

Implementors§

source§

impl<T> Magma for OpAdd<T>where T: Add<Output = T> + Eq + Sized,

§

type Set = T

source§

impl<T> Magma for OpAddCount<T>where T: Add<Output = T> + Eq + Sized,

§

type Set = (T, T)

source§

impl<T> Magma for OpAffine<T>where T: Add<Output = T> + Mul<Output = T> + Eq + Clone + Sized,

§

type Set = (T, T)

source§

impl<T> Magma for OpGcd<T>where T: Gcd + Eq + Sized,

§

type Set = T

source§

impl<T> Magma for OpMax<T>where T: Ord + Eq + Sized,

§

type Set = T

source§

impl<T> Magma for OpMin<T>where T: Ord + Eq + Sized,

§

type Set = T

source§

impl<T> Magma for OpMul<T>where T: Mul<Output = T> + Eq + Sized,

§

type Set = T

source§

impl<T: Eq, Op: Fn(T, T) -> T, Id: Fn() -> T> Magma for OpClosure<T, Op, Id>

§

type Set = T

source§

impl<const B: u64> Magma for OpRollHash<B>

§

type Set = (u64, u64)