Explorar el Código

add SelectionStep and InsertionStep class.

171870002 hace 5 años
padre
commit
0152a1c996

+ 2 - 0
src/main/java/com/example/data_structure/service/SortingService.java

@@ -190,4 +190,6 @@ public class SortingService {
         }
         return vo;
     }
+
+
 }

+ 67 - 0
src/main/java/com/example/data_structure/vo/InsertionStep.java

@@ -0,0 +1,67 @@
+package com.example.data_structure.vo;
+
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+
+@Component
+public class InsertionStep {
+    private String type; //有五个值:onSelect,onCompare,onExchange,onInsertion,allSorted
+    private int insertionIndex;
+    private ArrayList<Bar> content;
+
+    public InsertionStep(String type, ArrayList<Bar> content) {
+        this.type = type;
+        this.content = content;
+    }
+
+    public InsertionStep() {
+    }
+
+    //getter
+    public String getType() {
+        return type;
+    }
+
+    public ArrayList<Bar> getContent() {
+        return content;
+    }
+
+    public int getInsertionIndex() {
+        return insertionIndex;
+    }
+
+    //setter
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void setContent(ArrayList<Bar> content) {
+        this.content = content;
+    }
+
+    public void setInsertionIndex(int insertionIndex) {
+        this.insertionIndex = insertionIndex;
+    }
+
+    //toString
+
+    @Override
+    public String toString() {
+        return "InsertionStep{" +
+                "type='" + type + '\'' +
+                ", content=" + content +
+                '}';
+    }
+
+    //copy
+    public static ArrayList<Bar> copyContent(ArrayList<Bar> content){
+        ArrayList<Bar> copyContent=new ArrayList<Bar>();
+        for(int i=0;i<content.size();i++){
+            Bar bar=Bar.copyBar(content.get(i));
+            copyContent.add(bar);
+        }
+
+        return copyContent;
+    }
+}

+ 58 - 0
src/main/java/com/example/data_structure/vo/SelectionStep.java

@@ -0,0 +1,58 @@
+package com.example.data_structure.vo;
+
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+
+@Component
+public class SelectionStep {
+    private String type; //有五个值:beforeCompare,onExtreme,onCompare,beforeExchange,allSorted
+    private ArrayList<Bar> content;
+
+    public SelectionStep(String type, ArrayList<Bar> content) {
+        this.type = type;
+        this.content = content;
+    }
+
+    public SelectionStep() {
+    }
+
+    //getter
+    public String getType() {
+        return type;
+    }
+
+    public ArrayList<Bar> getContent() {
+        return content;
+    }
+
+    //setter
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void setContent(ArrayList<Bar> content) {
+        this.content = content;
+    }
+
+    //toString
+
+    @Override
+    public String toString() {
+        return "SelectionStep{" +
+                "type='" + type + '\'' +
+                ", content=" + content +
+                '}';
+    }
+
+    //copy
+    public static ArrayList<Bar> copyContent(ArrayList<Bar> content){
+        ArrayList<Bar> copyContent=new ArrayList<Bar>();
+        for(int i=0;i<content.size();i++){
+            Bar bar=Bar.copyBar(content.get(i));
+            copyContent.add(bar);
+        }
+
+        return copyContent;
+    }
+}