pub trait Identity: Magma {
    // Required method
    fn id(&self) -> Self::Set;
}
Expand description

単位元を持つ。

二項演算 $\circ: M \times M \to M$ が単位元を持つことを示す。 $$ x \in M \implies x \circ e = e \circ x = e. $$

Examples

use nekolib::traits::{Identity, Magma};
use nekolib::utils::OpMin;

let op_min = OpMin::default();
let x = 3;
assert_eq!(op_min.id(), std::i32::MAX);
assert_eq!(op_min.op(x, op_min.id()), x);

Required Methods§

source

fn id(&self) -> Self::Set

単位元を返す。

Implementors§

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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