This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::{Iterator, Peekable}; | |
// this struct lets you create an iterator from 2 sub iterators, and it will | |
// automatically return the interleaved, sorted results without much cost | |
struct OrderedIterator<I: Ord + Clone, P: Iterator<Item = I>> { | |
first: Peekable<P>, | |
second: Peekable<P>, | |
pop_from: usize, | |
first_empty: bool, | |
second_empty: bool, |