|
|
@@ -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;
|
|
|
+ }
|
|
|
+}
|