@@ -13,8 +13,8 @@ use std::sync::Arc;
13
13
use crate :: position:: { Position , PositionedIterator } ;
14
14
15
15
/// An iterator that returns the intersection of multiple iterators.
16
- pub struct IntersectionIterator < ' a , P : PositionedIterator > {
17
- base_iterator : P ,
16
+ pub struct IntersectionIterator < ' a > {
17
+ base_iterator : Box < dyn PositionedIterator > ,
18
18
other_iterators : Vec < Box < dyn PositionedIterator > > ,
19
19
min_heap : BinaryHeap < ReverseOrderPosition > ,
20
20
chromosome_order : & ' a HashMap < String , Chromosome > ,
@@ -127,7 +127,7 @@ fn region_str(p: &Position) -> std::string::String {
127
127
}
128
128
129
129
/// An iterator that returns the intersection of multiple iterators for each query interval
130
- impl < P : PositionedIterator > Iterator for IntersectionIterator < ' _ , P > {
130
+ impl Iterator for IntersectionIterator < ' _ > {
131
131
type Item = io:: Result < Intersections > ;
132
132
133
133
fn next ( & mut self ) -> Option < Self :: Item > {
@@ -211,9 +211,9 @@ impl<P: PositionedIterator> Iterator for IntersectionIterator<'_, P> {
211
211
}
212
212
213
213
/// Create a new IntersectionIterator given a query (base) and a vector of other positioned iterators.
214
- impl < ' a , P : PositionedIterator > IntersectionIterator < ' a , P > {
214
+ impl < ' a > IntersectionIterator < ' a > {
215
215
pub fn new (
216
- base_iterator : P ,
216
+ base_iterator : Box < dyn PositionedIterator > ,
217
217
other_iterators : Vec < Box < dyn PositionedIterator > > ,
218
218
chromosome_order : & ' a HashMap < String , Chromosome > ,
219
219
) -> io:: Result < Self > {
@@ -497,8 +497,9 @@ mod tests {
497
497
498
498
//let a_ivs: Box<dyn PositionedIterator> = Box::new(a_ivs);
499
499
500
- let mut iter = IntersectionIterator :: new ( a_ivs, vec ! [ Box :: new( b_ivs) ] , & chrom_order)
501
- . expect ( "error getting iterator" ) ;
500
+ let mut iter =
501
+ IntersectionIterator :: new ( Box :: new ( a_ivs) , vec ! [ Box :: new( b_ivs) ] , & chrom_order)
502
+ . expect ( "error getting iterator" ) ;
502
503
let mut n = 0 ;
503
504
assert ! ( iter. all( |intersection| {
504
505
let intersection = intersection. expect( "error getting intersection" ) ;
@@ -573,7 +574,7 @@ mod tests {
573
574
] ,
574
575
) ;
575
576
576
- let iter = IntersectionIterator :: new ( a_ivs, vec ! [ Box :: new( b_ivs) ] , & chrom_order)
577
+ let iter = IntersectionIterator :: new ( Box :: new ( a_ivs) , vec ! [ Box :: new( b_ivs) ] , & chrom_order)
577
578
. expect ( "error getting iterator" ) ;
578
579
iter. for_each ( |intersection| {
579
580
let intersection = intersection. expect ( "intersection" ) ;
@@ -609,8 +610,8 @@ mod tests {
609
610
} ,
610
611
] ,
611
612
) ;
612
- let mut iter =
613
- IntersectionIterator :: new ( a_ivs , vec ! [ ] , & chrom_order ) . expect ( "error getting iterator" ) ;
613
+ let mut iter = IntersectionIterator :: new ( Box :: new ( a_ivs ) , vec ! [ ] , & chrom_order )
614
+ . expect ( "error getting iterator" ) ;
614
615
615
616
let e = iter. nth ( 1 ) . expect ( "error getting next" ) ;
616
617
assert ! ( e. is_err( ) ) ;
@@ -639,8 +640,8 @@ mod tests {
639
640
} ,
640
641
] ,
641
642
) ;
642
- let mut iter =
643
- IntersectionIterator :: new ( a_ivs , vec ! [ ] , & chrom_order ) . expect ( "error getting iterator" ) ;
643
+ let mut iter = IntersectionIterator :: new ( Box :: new ( a_ivs ) , vec ! [ ] , & chrom_order )
644
+ . expect ( "error getting iterator" ) ;
644
645
645
646
let e = iter. nth ( 1 ) . expect ( "error getting next" ) ;
646
647
assert ! ( e. is_err( ) ) ;
@@ -684,8 +685,9 @@ mod tests {
684
685
] ,
685
686
) ;
686
687
687
- let mut iter = IntersectionIterator :: new ( a_ivs, vec ! [ Box :: new( b_ivs) ] , & chrom_order)
688
- . expect ( "error getting iterator" ) ;
688
+ let mut iter =
689
+ IntersectionIterator :: new ( Box :: new ( a_ivs) , vec ! [ Box :: new( b_ivs) ] , & chrom_order)
690
+ . expect ( "error getting iterator" ) ;
689
691
let e = iter. next ( ) . expect ( "error getting next" ) ;
690
692
assert ! ( e. is_err( ) ) ;
691
693
let e = e. err ( ) . unwrap ( ) ;
@@ -723,9 +725,12 @@ mod tests {
723
725
..Default :: default ( )
724
726
} ] ,
725
727
) ;
726
- let iter =
727
- IntersectionIterator :: new ( a_ivs, vec ! [ Box :: new( b_ivs) , Box :: new( c_ivs) ] , & chrom_order)
728
- . expect ( "error getting iterator" ) ;
728
+ let iter = IntersectionIterator :: new (
729
+ Box :: new ( a_ivs) ,
730
+ vec ! [ Box :: new( b_ivs) , Box :: new( c_ivs) ] ,
731
+ & chrom_order,
732
+ )
733
+ . expect ( "error getting iterator" ) ;
729
734
let c = iter
730
735
. map ( |intersection| {
731
736
let intersection = intersection. expect ( "error getting intersection" ) ;
@@ -765,7 +770,7 @@ mod tests {
765
770
..Default :: default ( )
766
771
} ] ,
767
772
) ;
768
- let iter = IntersectionIterator :: new ( a_ivs, vec ! [ Box :: new( b_ivs) ] , & chrom_order)
773
+ let iter = IntersectionIterator :: new ( Box :: new ( a_ivs) , vec ! [ Box :: new( b_ivs) ] , & chrom_order)
769
774
. expect ( "error getting iterator" ) ;
770
775
// check that it overlapped by asserting that the loop ran and also that there was an overlap within the loop.
771
776
let c = iter
0 commit comments