-
Notifications
You must be signed in to change notification settings - Fork 623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ordered stream utils #2517
base: master
Are you sure you want to change the base?
Ordered stream utils #2517
Conversation
fn gen_index(n: usize) -> usize { | ||
pub fn gen_index(n: usize) -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed an rng for the 'delayed streams' tests. pub(crate)
didn't seem to work for that, I guess because this is in futures-util and the tests are all in futures.
// For reference | ||
// diff :: Ord a => [a] -> [a] -> [a] | ||
// diff (x : xs) (y : ys) | ||
// | x == y = diff xs ys | ||
// | x < y = x : diff xs (y : ys) | ||
// | x > y = diff (x : xs) ys | ||
// diff xs [] = xs | ||
// diff [] _ = [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prototyped the actual algorithm in Haskell. Happy to delete this if it's not helpful.
e06c362
to
fe03c97
Compare
Fixed the rest of the CI failures. Please let me know if you'd like me to squash everything from 4e01c51 on. |
This adds utility functions for merge and diff operations on sorted streams in constant space. I had a problem at work where I needed to diff a sorted stream of database items with the keys of a bunch of s3 buckets. The generic versions of those functions seem generic enough to merit inclusion here.