Skip to content

Commit 8cce2b4

Browse files
committed
remove own random array function
1 parent c9fe628 commit 8cce2b4

File tree

3 files changed

+1
-50
lines changed

3 files changed

+1
-50
lines changed

benches/sort_benchmark.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, BatchSize};
22
use rand::{distributions::Uniform, Rng};
3-
use sorting_algorithm::bubblesort;
4-
use sorting_algorithm::mergesort;
5-
use sorting_algorithm::quicksort;
6-
use sorting_algorithm::insertionsort;
7-
use sorting_algorithm::shellsort;
3+
use sorting_algorithm::{bubblesort, insertionsort, mergesort, quicksort, shellsort};
84

95
fn sorting_benchmarks(c: &mut Criterion) {
106
let mut group = c.benchmark_group("Sorting Algorithms");

src/lib.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,9 @@ pub use insertion_sort::insertionsort;
1010
pub use merge_sort::mergesort;
1111
pub use shell_sort::shellsort;
1212

13-
use rand::Rng;
14-
use std::{ops::Range, ops::RangeBounds, ops::Bound};
15-
pub fn generate_random_array(range: Range<u32>, size: u32) -> Vec<u32> {
16-
match (range.start_bound(), range.end_bound()){
17-
(Bound::Included(start), Bound::Excluded(end)) => { // TODO: should only be included
18-
if start >= end {
19-
panic!("Start bound must be less than end bound"); // 3..0
20-
}
21-
},
22-
_=> panic!("Unsupported rangebound") // marcro: unimplemented!() (Error if chase is not covered)
23-
}
24-
25-
let mut arr: Vec<u32> = Vec::with_capacity(size as usize);
26-
27-
let mut rng = rand::thread_rng();
28-
29-
for _ in 0..size {
30-
arr.push(rng.gen_range(range.clone()));
31-
}
32-
33-
arr
34-
}
35-
36-
3713
#[cfg(test)]
3814
mod tests {
3915
use super::*;
40-
41-
/// Unit tests for generate_random_array
42-
#[test]
43-
fn test_generate_random_array(){
44-
let arr = generate_random_array(0..100, 1000);
45-
assert_eq!(arr.len(), 1000);
46-
}
47-
4816
///
4917
/// Test sorting algorithms
5018
///

src/main.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)