@@ -38,14 +38,17 @@ pub struct SampleUnstableFolder {
3838}
3939
4040impl < Item > FolderSync < Item > for SampleUnstableFolder {
41- type Done = SASampleUnstable < Item > ;
41+ type State = SASampleUnstable < Item > ;
42+ type Done = Self :: State ;
4243
43- fn zero ( & mut self ) -> Self :: Done {
44+ fn zero ( & mut self ) -> Self :: State {
4445 SASampleUnstable :: new ( self . samples )
4546 }
46- fn push ( & mut self , state : & mut Self :: Done , item : Item ) {
47+ fn push ( & mut self , state : & mut Self :: State , item : Item ) {
4748 state. push ( item, & mut thread_rng ( ) )
4849 }
50+ fn done ( & mut self , state : Self :: State ) -> Self :: Done { state }
51+
4952}
5053
5154#[ derive( new) ]
@@ -83,14 +86,17 @@ impl<Item> FolderSync<Item> for MostFrequentFolder
8386where
8487 Item : Clone + Hash + Eq + Send + ' static ,
8588{
86- type Done = Top < Item , usize > ;
89+ type State = Top < Item , usize > ;
90+ type Done = Self :: State ;
8791
88- fn zero ( & mut self ) -> Self :: Done {
92+ fn zero ( & mut self ) -> Self :: State {
8993 Top :: new ( self . n , self . probability , self . tolerance , ( ) )
9094 }
91- fn push ( & mut self , state : & mut Self :: Done , item : Item ) {
95+ fn push ( & mut self , state : & mut Self :: State , item : Item ) {
9296 state. push ( item, & 1 )
9397 }
98+ fn done ( & mut self , state : Self :: State ) -> Self :: Done { state }
99+
94100}
95101
96102#[ derive( new) ]
@@ -137,12 +143,15 @@ where
137143 A : Clone + Hash + Eq + Send + ' static ,
138144 B : Hash + ' static ,
139145{
140- type Done = Top < A , HyperLogLogMagnitude < B > > ;
146+ type State = Top < A , HyperLogLogMagnitude < B > > ;
147+ type Done = Self :: State ;
141148
142- fn zero ( & mut self ) -> Self :: Done {
149+ fn zero ( & mut self ) -> Self :: State {
143150 Top :: new ( self . n , self . probability , self . tolerance , self . error_rate )
144151 }
145- fn push ( & mut self , state : & mut Self :: Done , item : ( A , B ) ) {
152+ fn push ( & mut self , state : & mut Self :: State , item : ( A , B ) ) {
146153 state. push ( item. 0 , & item. 1 )
147154 }
155+ fn done ( & mut self , state : Self :: State ) -> Self :: Done { state }
156+
148157}
0 commit comments