A small crate of commonly used sorting algorithms for any generic type that implements PartialOrd and copy.
The crate can be found here: Crate
rust
[dependencies]
rs_algo = "0.1"
```rust use rsalgo::sort::*; use rsalgo::compare::LCS;
fn main() { let mut a = vec![117, 1, 3, 99, 10, 7, 7, 2, 11, -5, 4, 9, 32, 1, 3, 99, 10, 7]; let mut b = vec![117, 1, 3, 99, 10, 7, 7, 2, 11, -5, 4, 9, 817, 1, 3, 99, 10, 7]; let mut c = vec![117, 1, 3, 99, 10, 7, 7, 2, 11, -5, 4, 9, 817, 1, 3, 99, 10, 7]; let mut d = vec!["apple", "cake", "lemon", "zuccini", "berry", "black berry", "kit kat"];
let time = merge::sortwithtime(&mut a); println!("merge sorted: time {:?}", time);
let time = quick::sortwithtime(&mut b); println!("quick sorted: time {:?}", time);
let time = insertion::sortwithtime(&mut c); println!("insertion sorted: time {:?}", time);
let time = bubble::sortwithtime(&mut d); println!("bubble sorted: time {:?}", time);
// get a new longest common sequence object let lcs = LCS::newsubsequence("leighxxxft".tostring(), "right".tostring()); println!("lcs is = {}", lcs.subsequencelen); println!("longest common subsequence = {}", lcs.getlongestsubsequence().expect("no lcs found")); } ```
MIT