File tree Expand file tree Collapse file tree 3 files changed +31
-19
lines changed Expand file tree Collapse file tree 3 files changed +31
-19
lines changed Original file line number Diff line number Diff line change @@ -98,21 +98,26 @@ where
98
98
}
99
99
100
100
/// Moves all recent tuples from `input1` that are not present in `input2` into `output`.
101
- pub ( crate ) fn antijoin < Key : Ord , Val : Ord , Result : Ord > (
102
- input1 : & Relation < ( Key , Val ) > ,
103
- input2 : & Relation < Key > ,
104
- mut logic : impl FnMut ( & Key , & Val ) -> Result ,
105
- ) -> Relation < Result > {
101
+ pub ( crate ) fn antijoin < P , A , O > (
102
+ input1 : & Relation < A > ,
103
+ input2 : & Relation < P > ,
104
+ mut logic : impl FnMut ( A ) -> O ,
105
+ ) -> Relation < O >
106
+ where
107
+ A : Copy + Split < P > ,
108
+ P : Ord ,
109
+ O : Ord ,
110
+ {
106
111
let mut tuples2 = & input2[ ..] ;
107
112
108
113
let results = input1
109
114
. elements
110
115
. iter ( )
111
- . filter ( |( ref key , _ ) | {
112
- tuples2 = gallop ( tuples2, |k| k < key ) ;
113
- tuples2. first ( ) != Some ( key )
116
+ . filter ( |el | {
117
+ tuples2 = gallop ( tuples2, |p| p < & el . prefix ( ) ) ;
118
+ tuples2. first ( ) != Some ( & el . prefix ( ) )
114
119
} )
115
- . map ( |( ref key , ref val ) | logic ( key , val ) )
120
+ . map ( |& el | logic ( el ) )
116
121
. collect :: < Vec < _ > > ( ) ;
117
122
118
123
Relation :: from_vec ( results)
Original file line number Diff line number Diff line change @@ -67,11 +67,15 @@ impl<Tuple: Ord> Relation<Tuple> {
67
67
/// tuples with the `logic` closure. Like
68
68
/// [`Variable::from_antijoin`] except for use where the inputs
69
69
/// are not varying across iterations.
70
- pub fn from_antijoin < Key : Ord , Val1 : Ord > (
71
- input1 : & Relation < ( Key , Val1 ) > ,
72
- input2 : & Relation < Key > ,
73
- logic : impl FnMut ( & Key , & Val1 ) -> Tuple ,
74
- ) -> Self {
70
+ pub fn from_antijoin < P , A > (
71
+ input1 : & Relation < A > ,
72
+ input2 : & Relation < P > ,
73
+ logic : impl FnMut ( A ) -> Tuple ,
74
+ ) -> Self
75
+ where
76
+ P : Ord ,
77
+ A : Copy + Split < P >
78
+ {
75
79
join:: antijoin ( input1, input2, logic)
76
80
}
77
81
Original file line number Diff line number Diff line change @@ -180,12 +180,15 @@ impl<Tuple: Ord> Variable<Tuple> {
180
180
/// let result = variable.complete();
181
181
/// assert_eq!(result.len(), 16);
182
182
/// ```
183
- pub fn from_antijoin < K : Ord , V : Ord > (
183
+ pub fn from_antijoin < P , A > (
184
184
& self ,
185
- input1 : & Variable < ( K , V ) > ,
186
- input2 : & Relation < K > ,
187
- logic : impl FnMut ( & K , & V ) -> Tuple ,
188
- ) {
185
+ input1 : & Variable < A > ,
186
+ input2 : & Relation < P > ,
187
+ logic : impl FnMut ( A ) -> Tuple ,
188
+ ) where
189
+ A : Copy + Split < P > ,
190
+ P : Ord ,
191
+ {
189
192
self . insert ( join:: antijoin ( & input1. recent . borrow ( ) , input2, logic) )
190
193
}
191
194
You can’t perform that action at this time.
0 commit comments