An open API service indexing awesome lists of open source software.

https://github.com/defi0x1/strategy-pattern

Combined sort-algorithm with strategy pattern
https://github.com/defi0x1/strategy-pattern

design-patterns rust-lang sorting-algorithms strategy-pattern

Last synced: 5 months ago
JSON representation

Combined sort-algorithm with strategy pattern

Awesome Lists containing this project

README

          

# Learning: strategy-pattern

Combined sort-algorithm with strategy pattern for learning purpose. Easy to switching between sort algorithm to test

```rs
fn main() {
println!("----Sort numbers----");

let mut arr = [4, 5, 2, -31, 0, 23, 8, 7, 1];
println!("Before: {:?}", arr);

Sort::sort(SelectionSort, &mut arr);
println!("After: {:?}\n", arr);

println!("----Sort strings----");

let mut strings = ["money", "crypto", "stock", "car", "house", "gold"];
println!("Before: {:?}", strings);

Sort::sort(SelectionSort, &mut strings);
println!("After: {:?}\n", strings);
}
```

# TODO
- [ ] Add measure performance (show run time)
- [ ] Add cli
- [ ] Impl count sort
- [ ] Impl merge sort