Crates.io | searchsort |
lib.rs | searchsort |
version | 0.1.0 |
source | src |
created_at | 2023-09-09 22:02:02.666437 |
updated_at | 2023-09-09 22:02:02.666437 |
description | A Rust trait implementing Binary Search and Quick Sort algorithms. |
homepage | https://github.com/manorajesh/searchsort |
repository | https://github.com/manorajesh/searchsort.git |
max_upload_size | |
id | 968409 |
size | 11,936 |
A Rust trait implementing a Binary Search and the Quick Sort algorithm. Currently, they are implemented for
Vec<T>
types but can be expanded to other collection types.
cargo add searchsort
use searchsort::SearchSort;
let arr = vec![4, 82, 4, 32, 3, 20, 3, 2, 2, 9, 8, 7, 5, 0];
let find = 5;
assert_eq!(arr.find_me(find, 0, arr.len()-1), Some(12));
let mut arr = vec![3, 1, 4, 1, 5, 9, 2, 6, 5];
arr.quicksort();
assert_eq!(arr, [1, 1, 2, 3, 4, 5, 5, 6, 9]);
This was my first time implementing the Binary Search and Quick Sort algorithms. I have a feeling this may not be the last time.