|
@@ -1,4 +1,71 @@
|
|
|
package com.example.data_structure.domain;
|
|
package com.example.data_structure.domain;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+
|
|
|
public class Sorting {
|
|
public class Sorting {
|
|
|
|
|
+ private int size; //元素个数
|
|
|
|
|
+ private String elementType; //可以有 String,int,double,char 四种值
|
|
|
|
|
+ private ArrayList<Object> content; //内容
|
|
|
|
|
+ private boolean isDesc; //规则是否为降序
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构造方法
|
|
|
|
|
+ * @param elementType
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param isDesc
|
|
|
|
|
+ */
|
|
|
|
|
+ public Sorting(String elementType, ArrayList<Object> content, boolean isDesc) {
|
|
|
|
|
+ this.elementType = elementType;
|
|
|
|
|
+ this.content = content;
|
|
|
|
|
+ this.isDesc = isDesc;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ *判断是否需要交换顺序(结合规则是否为降序和比较结果判断)
|
|
|
|
|
+ * @param compareResult a b比较的结果
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean isReverse(boolean compareResult){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean charCompare(char a,char b){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean stringCompare(String a,String b){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean intCompare(int a,int b){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean doubleCompare(double a,double b){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 记录冒泡排序每一趟中每一次交换的结果
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ArrayList<ArrayList<Object>> bubbleSort(){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 记录插入排序每插入一个数之后的结果
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ArrayList<ArrayList<Object>> insertionSort(){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 记录选择排序每选择一个数之后的结果
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ArrayList<ArrayList<Object>> selectionSort(){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|