This repository was archived by the owner on Mar 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSorter.java
More file actions
48 lines (47 loc) · 1.45 KB
/
Sorter.java
File metadata and controls
48 lines (47 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.ArrayList;
/*
* Primarily for the Sort Menu
* abstract because this class should never be instantiated
*/
public abstract class Sorter
{
/*
* Method to run the sort and return the sortResults object
*/
public static sortResults sort(sortParams sParams)
{
ArrayList<sortResults> results = new ArrayList<sortResults>();
ExpParams e = new ExpParams();
//saving the values that get changed during dummyruns
int threshold = sParams.getThreshold();
int arrSize = sParams.getArrSize();
int[] arr = sParams.getArray();
//building Experiment parameters based on user output
e.setArrSize(sParams.getArrSize());
e.setGenArrayType(GenArrayType.RANDOM);
e.setSortType(sParams.getSortType());
e.setGapSeqType(sParams.getGapSeqType());
e.setNumOfIterations(10);
e.setSortType(sParams.getSortType());
if(e.getSortType() == sortType.SHELL)
{
sParams.setGapSeq(GapSeqGenerator.generateGapSeq(sParams));
}
sParams.setStartIndex(0);
sParams.setMemUsage(0);
Sort sorter = null;
sorter = chooseAlgorithm.chooseSortAlgo(sorter, e);
DummyRuns.RunDummy(e, sParams, sorter);
//reverting changes from dummyruns
sParams.setThreshold(threshold);
sParams.setArrSize(arrSize);
e.setArrSize(arrSize);
sParams.setArray(arr);
sParams.setMemUsage(0);
sorter.initialize(sParams);
//sorting
doSort.runSort(e, sParams, sorter, sParams.getArrSize(), results);
//returning the first and only result logged
return results.get(0);
}
}