4 releases

0.2.0 Feb 19, 2022
0.1.2 Feb 1, 2022
0.1.1 Feb 1, 2022
0.1.0 Feb 1, 2022

#946 in Asynchronous

MIT/Apache

14KB
215 lines

Stream KMerge

K-way merge for rust streams.

build_status crates.io

How to use with Cargo:

[dependencies]
stream-kmerge = "0.1"

How to use in your crate:

use stream_kmerge::kmerge_by;

Example

use futures::{stream, StreamExt};
use stream_kmerge::kmerge_by;

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let streams = vec![stream::iter(vec![1, 3, 5]), stream::iter(vec![2, 3, 4])];

    assert_eq!(
        kmerge_by(streams, |x: &usize, y: &usize| y.cmp(&x)).collect::<Vec<usize>>().await,
        vec![1, 2, 3, 3, 4, 5],
    );
}

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 or the MIT license https://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

Portions of the project have been copied from https://github.com/rust-itertools/itertools which is copyrighted under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 or the MIT license https://opensource.org/licenses/MIT, at your option. See https://github.com/rust-itertools/itertools/blob/6c4fc2f8e745fe4780578dfa4feb44ccccffb521/src/kmerge_impl.rs for the original code.

Dependencies

~1MB
~17K SLoC