rust-lang-nursery / rust-cookbook

https://rust-lang-nursery.github.io/rust-cookbook
Creative Commons Zero v1.0 Universal
2.25k stars 284 forks source link

New Recipes #434

Open AndyGauge opened 6 years ago

AndyGauge commented 6 years ago

Create an issue for each of the recipes

These were taken from https://paper.dropbox.com/doc/Cookbook-new-recipe-list--AHhY6tZWu74Ju8uewuP5J87BAg-oRJe83bTkNE4Gk2Qmvu5V

AndyGauge commented 6 years ago

@budziq can you review this list? This is from when @withoutboats and @aturon were planning new recipes. I'm happy to create the issues, but before officially adopting them, I'm hoping for your input. There are also opportunities in here to expand our adopted crates so cc https://github.com/rust-lang-nursery/ecosystem-wg/issues/22

budziq commented 6 years ago

can you review this list

@AndyGauge Sure! It looks very cool on the first glance, but I'll need some time to give any reasonable feadback. Some assorted musings:

AndyGauge commented 6 years ago
budziq commented 6 years ago

@AndyGauge :+1: Sorry for taking so long. Imho all of these are valid points. Lets go with these recipes!

Frederik-Baetens commented 5 years ago

Hello, I don't know if I should post this here but, I have an implementation of an algorithm for the closest pair of points problem. It is a very nice use case of a btreeset, since the data needs to be sorted, and inserted into at random points.

For each point in a vec of points sorted by x coordinate, the algorithm calculates the distance only to points that are within the square around it with a diameter of 2*(min distance so far) as shown here For the horizontal dimension, you can just use the fact that you're working in a sorted vec, but to keep track of proximity in a second dimension, a btreeset is useful. You basically insert points into the btreeset as you pass over them in your for loop. Then you will know which points are close in the x dimension based on the sorted vec, and you will know which points are close in the y direction based on the BtreeSet.

If you think this is a good idea I'd be glad to clean up my code and try to submit a pull request.