Hot answers tagged

4 votes
Accepted

Multithreaded bogosort in Rust

List of improvements I would make: I'm uncertain why you use Arc::clone(...), just use .clone() directly. Same for ...
user avatar
  • 301
3 votes

Sort and search vectors by different criteria

Unnecessary sorting of data You should be able to find the desired items in \$\mathcal{O}(N)\$ time without needing to sort the container multiple times. You can just linearly go through the items in ...
user avatar
  • 32.4k
2 votes

Find first and last matches on a sorted list

Binary search This should be a binary search as that is the expected algorithm. Why? because the array is sorted. Your function does not take advantage of the fact that the elements are sorted. ...
user avatar
  • 19.9k
2 votes
Accepted

Partitioning a list so that even numbers appear before odd numbers

welcome to the Rust community! Your code is already quite idiomatic. You may use an unsafe and unstable feature to improve efficiency, swap_unchecked. It's only ...
user avatar
2 votes

Multithreaded bogosort in Rust

You definitely want access to shared stuff to be read-only in the normal case so multiple threads can do it in parallel. Reading a lock-free atomic simply works that way, unlike taking a lock around ...
user avatar
  • 2,632

Only top scored, non community-wiki answers of a minimum length are eligible