0.3.1 |
|
---|---|
0.3.0 |
|
0.2.0 |
|
0.1.2 |
|
#37 in #binary-search
17KB
286 lines
search-sort
Implementation of few searching and sorting algorithms. This crate is currently WIP, and supports only few of them.
Searching algorithms to be implemented:
- linear search
- binary search
- jump search
- exponential search
Sorting algorithms to be implemented:
- bubble sort
- quick sort
- parallel quick sort
- merge sort
- insertion sort
- heap sort
- radix sort
Quick example
Add this to your Cargo.toml
file:
[dependencies]
search-sort = "0.3"
This code sorts the slice
and searches for elements in it:
use search_sort::{search, sort};
let mut slice = [5, 1, 91, -45, 11, 5];
sort::quick(&mut slice);
assert_eq!(slice, [-45, 1, 5, 5, 11, 91]);
assert_eq!(Some(2), search::binary_first(&slice, &5));
assert_eq!(None, search::binary_first(&slice, &42));
License
This code is released under the MIT license. See the LICENSE.md file.
lib.rs
:
An implementation of few searching and sorting algorithms.
This crate is currently WIP, and supports only few of them. Currently supported algorithms:
Quick example
use search_sort::{search, sort};
let mut slice = [5, 1, 91, -45, 11, 5];
sort::quick(&mut slice);
assert_eq!(slice, [-45, 1, 5, 5, 11, 91]);
assert_eq!(Some(2), search::binary_first(&slice, &5));
assert_eq!(None, search::binary_first(&slice, &42));