File tree Expand file tree Collapse file tree 6 files changed +21
-19
lines changed Expand file tree Collapse file tree 6 files changed +21
-19
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use alga::general::Operator;
22use std:: ops:: Range ;
33
44/// An abstract data type which maintains a time-ordered sliding window.
5- pub trait TimeWindow < Time , Value , BinOp >
5+ pub trait TimeWindow < Time , Value , BinOp > : Clone
66where
77 Time : Ord ,
88 BinOp : Operator ,
1818}
1919
2020/// An abstract data type which maintains a fifo-ordered sliding window.
21- pub trait FifoWindow < Value , BinOp >
21+ pub trait FifoWindow < Value , BinOp > : Clone
2222where
2323 BinOp : Operator ,
2424{
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use alga::general::AbstractMonoid;
22use alga:: general:: Operator ;
33use std:: collections:: HashSet ;
44
5- pub ( crate ) trait FAT < Value , BinOp >
5+ pub ( crate ) trait FAT < Value , BinOp > : Clone
66where
77 Value : AbstractMonoid < BinOp > + Clone ,
88 BinOp : Operator ,
3333 fn suffix ( & self , i : usize ) -> Value ;
3434}
3535
36+ #[ derive( Clone ) ]
3637pub ( crate ) struct FlatFAT < Value , BinOp >
3738where
3839 Value : AbstractMonoid < BinOp > + Clone ,
@@ -141,7 +142,7 @@ where
141142 let leaf = self . leaf ( idx) ;
142143 self . tree [ leaf] = val;
143144 } ) ;
144- ( 0 ..self . leaf ( 0 ) ) . into_iter ( ) . rev ( ) . for_each ( |parent| {
145+ ( 0 ..self . leaf ( 0 ) ) . rev ( ) . for_each ( |parent| {
145146 let left = self . left ( parent) ;
146147 let right = self . right ( parent) ;
147148 self . tree [ parent] = self . tree [ left] . operate ( & self . tree [ right] ) ;
@@ -163,7 +164,7 @@ where
163164 }
164165 node = parent;
165166 }
166- return agg;
167+ agg
167168 }
168169
169170 fn suffix ( & self , i : usize ) -> Value {
@@ -176,6 +177,6 @@ where
176177 }
177178 node = parent;
178179 }
179- return agg;
180+ agg
180181 }
181182}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use crate::FifoWindow;
55use alga:: general:: AbstractMonoid ;
66use alga:: general:: Operator ;
77
8+ #[ derive( Clone ) ]
89pub struct Reactive < Value , BinOp >
910where
1011 Value : AbstractMonoid < BinOp > + Clone ,
3132 }
3233 }
3334 fn inverted ( & self ) -> bool {
34- return self . front > self . back ;
35+ self . front > self . back
3536 }
3637 fn resize ( & mut self , capacity : usize ) {
3738 let leaves = self . fat . leaves ( ) ;
Original file line number Diff line number Diff line change 11use crate :: FifoWindow ;
22use alga:: general:: AbstractMonoid ;
33use alga:: general:: Operator ;
4- use std:: marker:: PhantomData ;
54use std:: collections:: VecDeque ;
5+ use std:: marker:: PhantomData ;
66
7- #[ derive( Debug ) ]
7+ #[ derive( Clone ) ]
88pub struct ReCalc < Value , BinOp >
99where
1010 Value : AbstractMonoid < BinOp > + Clone ,
1919 Value : AbstractMonoid < BinOp > + Clone ,
2020 BinOp : Operator ,
2121{
22- fn new ( ) -> ReCalc < Value , BinOp > {
23- ReCalc {
22+ fn new ( ) -> Self {
23+ Self {
2424 stack : VecDeque :: new ( ) ,
2525 op : PhantomData ,
2626 }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use alga::general::Operator;
44use std:: collections:: VecDeque ;
55use std:: marker:: PhantomData ;
66
7- #[ derive( Debug ) ]
7+ #[ derive( Clone ) ]
88pub struct SoE < Value , BinOp >
99where
1010 Value : AbstractGroup < BinOp > + Clone ,
2020 Value : AbstractGroup < BinOp > + Clone ,
2121 BinOp : Operator ,
2222{
23- fn new ( ) -> SoE < Value , BinOp > {
24- SoE {
23+ fn new ( ) -> Self {
24+ Self {
2525 stack : VecDeque :: new ( ) ,
2626 agg : Value :: identity ( ) ,
2727 op : PhantomData ,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use alga::general::AbstractMonoid;
33use alga:: general:: Operator ;
44use std:: marker:: PhantomData ;
55
6- #[ derive( Debug ) ]
6+ #[ derive( Clone ) ]
77struct Item < Value >
88where
99 Value : Clone ,
1212 val : Value ,
1313}
1414
15- #[ derive( Debug ) ]
15+ #[ derive( Clone ) ]
1616pub struct TwoStacks < Value , BinOp >
1717where
1818 Value : AbstractMonoid < BinOp > + Clone ,
2828 Value : AbstractMonoid < BinOp > + Clone ,
2929 BinOp : Operator ,
3030{
31- fn new ( ) -> TwoStacks < Value , BinOp > {
32- TwoStacks {
31+ fn new ( ) -> Self {
32+ Self {
3333 front : Vec :: new ( ) ,
3434 back : Vec :: new ( ) ,
3535 op : PhantomData ,
6363 BinOp : Operator ,
6464{
6565 #[ inline( always) ]
66- fn agg ( stack : & Vec < Item < Value > > ) -> Value {
66+ fn agg ( stack : & [ Item < Value > ] ) -> Value {
6767 if let Some ( top) = stack. last ( ) {
6868 top. agg . clone ( )
6969 } else {
You can’t perform that action at this time.
0 commit comments