Skip to content
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

Adds search unordered items in parallel example #337

Merged
merged 1 commit into from Oct 24, 2017

Conversation

Projects
None yet
2 participants
@j-haj
Copy link
Contributor

j-haj commented Oct 17, 2017

cc #330

@j-haj

This comment has been minimized.

Copy link
Contributor Author

j-haj commented Oct 17, 2017

Didn't mean for c3f4a42 do be included in this.. I will rebase and push and update

@j-haj j-haj force-pushed the j-haj:rayon-search branch from 234ba46 to 709d96a Oct 17, 2017

@budziq
Copy link
Collaborator

budziq left a comment

Well done @j-haj!

I'd suggest just two minor changes

let f2 = v.par_iter().find_any(|&&x| x % 2 == 0 && x > 6);
let f3 = v.par_iter().find_any(|&&x| x > 8);
if let Some(found_9) = f1 {

This comment has been minimized.

@budziq

budziq Oct 17, 2017

Collaborator

How about writing it more concisely as

    assert_eq!(f1, Some(&9));
    assert_eq!(f2, Some(&8));
    assert!(f3 > Some(&8))

This comment has been minimized.

@j-haj

j-haj Oct 17, 2017

Author Contributor

This is much cleaner. It did not occur to me to convert the expected value into an optional. Very clever! 👍

@@ -72,6 +73,46 @@ fn main() {
}
```

[ex-rayon-parallel-search]: #ex-rayon-parallel-search
<a name="ex-rayon-parallel-search"></a>
## Search unordered items in parallel

This comment has been minimized.

@budziq

budziq Oct 17, 2017

Collaborator

Hmm we might want to change the example title to something along the lines of
"Search items with given predicate in parallel". Originally the "unordered" part was to emphasize that we are not doing binary search but I think that mentioning the arbitrary predicate is a stronger usecase.

@j-haj

This comment has been minimized.

Copy link
Contributor Author

j-haj commented Oct 17, 2017

Great suggestions! I'll push some updates later this evening

@j-haj j-haj force-pushed the j-haj:rayon-search branch from 709d96a to bde8bb6 Oct 18, 2017

@j-haj

This comment has been minimized.

Copy link
Contributor Author

j-haj commented Oct 18, 2017

I slightly modified the suggested title to "Search items using given predicate in parallel" to make it clear the predicate is associated with the search rather than the items.

@budziq budziq merged commit de94b25 into rust-lang-nursery:master Oct 24, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@budziq

This comment has been minimized.

Copy link
Collaborator

budziq commented Oct 24, 2017

Nicely done @j-haj !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.