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
26
27
28
29
30
31
use super::op_add;
use super::op_max;
use super::super::traits::action;
use super::super::traits::additive;
use super::super::traits::binop;
use super::super::traits::min;
use std::fmt::Debug;
use std::ops::Add;

use action::MonoidAction;
use additive::{AddAssoc, Zero};
use binop::Magma;
use min::Min;
use op_add::OpAdd;
use op_max::OpMax;

#[derive(Clone, Copy, Debug, Default)]
pub struct OpAddOnOpMax<T> {
    op_add: OpAdd<T>,
    op_max: OpMax<T>,
}

impl<T: Ord + Eq + Add<Output = T> + AddAssoc + Zero + Min + Sized> MonoidAction
    for OpAddOnOpMax<T>
{
    type Operand = OpMax<T>;
    type Operator = OpAdd<T>;
    fn operand(&self) -> &Self::Operand { &self.op_max }
    fn operator(&self) -> &Self::Operator { &self.op_add }
    fn act(&self, x: T, op: T) -> T { self.op_add.op(x, op) }
}