#tournament #tree #merge #sorting #kway

tournament-kway

Implementation of a k-way merge using a tournament tree

2 releases

0.1.1 Mar 18, 2025
0.1.0 Apr 22, 2022

#404 in Data structures

Download history 107/week @ 2024-12-16 21/week @ 2024-12-23 20/week @ 2024-12-30 46/week @ 2025-01-06 60/week @ 2025-01-13 171/week @ 2025-01-20 199/week @ 2025-01-27 182/week @ 2025-02-03 129/week @ 2025-02-10 82/week @ 2025-02-17 119/week @ 2025-02-24 177/week @ 2025-03-03 202/week @ 2025-03-10 328/week @ 2025-03-17 296/week @ 2025-03-24 125/week @ 2025-03-31

955 downloads per month

MIT/Apache

17KB
402 lines

tournament

An implementation of a k-way merge iterator using a binary heap. The k-way merge iterator is very useful when given k sets of sorted data, you want to find the n top elements in between the sets in an efficient way, without sorting the entire data set.

Imagine having dozens of slices with hundreds of elements, where you only care about the top 10.

use tournament::Tournament;

let t = Tournament::from_iters_min([(1..2000), (1..20000), (1..5000000)]);
assert_eq!(t.take(5).collect::<Vec<_>>(), [1, 1, 1, 2, 2]);

License: MIT OR Apache-2.0

Dependencies

~97KB