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
- Host: GitHub
- URL: https://github.com/defi0x1/strategy-pattern
- Owner: defi0x1
- License: apache-2.0
- Created: 2022-09-20T08:01:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T05:41:22.000Z (almost 3 years ago)
- Last Synced: 2025-06-26T06:45:58.264Z (8 months ago)
- Topics: design-patterns, rust-lang, sorting-algorithms, strategy-pattern
- Language: Rust
- Homepage:
- Size: 216 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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