35 |
37 |
36 void testRadixSort() { |
38 void testRadixSort() { |
37 int n = 10000000; |
39 int n = 10000000; |
38 vector<int> data(n); |
40 vector<int> data(n); |
39 for (int i = 0; i < n; ++i) { |
41 for (int i = 0; i < n; ++i) { |
40 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500; |
42 data[i] = rnd[1000] - 500; |
41 } |
43 } |
42 radixSort(data.begin(), data.end()); |
44 radixSort(data.begin(), data.end()); |
43 } |
45 } |
44 |
46 |
45 |
47 |
46 void testCounterSort() { |
48 void testCounterSort() { |
47 int n = 10000000; |
49 int n = 10000000; |
48 vector<int> data(n); |
50 vector<int> data(n); |
49 for (int i = 0; i < n; ++i) { |
51 for (int i = 0; i < n; ++i) { |
50 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500; |
52 data[i] = rnd[1000] - 500; |
51 } |
53 } |
52 counterSort(data.begin(), data.end()); |
54 counterSort(data.begin(), data.end()); |
53 } |
55 } |
54 |
56 |
55 void testSort() { |
57 void testSort() { |
56 int n = 10000000; |
58 int n = 10000000; |
57 vector<int> data(n); |
59 vector<int> data(n); |
58 for (int i = 0; i < n; ++i) { |
60 for (int i = 0; i < n; ++i) { |
59 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500; |
61 data[i] = rnd[1000] - 500; |
60 } |
62 } |
61 sort(data.begin(), data.end()); |
63 sort(data.begin(), data.end()); |
62 } |
64 } |
63 |
65 |
64 void testStableSort() { |
66 void testStableSort() { |
65 int n = 10000000; |
67 int n = 10000000; |
66 vector<int> data(n); |
68 vector<int> data(n); |
67 for (int i = 0; i < n; ++i) { |
69 for (int i = 0; i < n; ++i) { |
68 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500; |
70 data[i] = rnd[1000] - 500; |
69 } |
71 } |
70 stable_sort(data.begin(), data.end()); |
72 stable_sort(data.begin(), data.end()); |
71 } |
73 } |
72 |
74 |
73 void testSorts() { |
75 void testSorts() { |