QuickStep.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package com.example.data_structure.vo;
  2. import org.springframework.stereotype.Component;
  3. import java.util.ArrayList;
  4. @Component
  5. public class QuickStep {
  6. private String type; //有六个值: beforeSelectPivot,onSelectPivot,onCompare,onExchange,onConfirm,allSorted
  7. private ArrayList<Bar> content;
  8. public QuickStep(String type, ArrayList<Bar> content) {
  9. this.type = type;
  10. this.content = content;
  11. }
  12. public QuickStep() {
  13. }
  14. //getter
  15. public String getType() {
  16. return type;
  17. }
  18. public ArrayList<Bar> getContent() {
  19. return content;
  20. }
  21. //setter
  22. public void setType(String type) {
  23. this.type = type;
  24. }
  25. public void setContent(ArrayList<Bar> content) {
  26. this.content = content;
  27. }
  28. //toString
  29. @Override
  30. public String toString() {
  31. return "QuickStep{" +
  32. "type='" + type + '\'' +
  33. ", content=" + content +
  34. '}';
  35. }
  36. //copy
  37. public static ArrayList<Bar> copyContent(ArrayList<Bar> content){
  38. ArrayList<Bar> copyContent=new ArrayList<Bar>();
  39. for(int i=0;i<content.size();i++){
  40. Bar bar=Bar.copyBar(content.get(i));
  41. copyContent.add(bar);
  42. }
  43. return copyContent;
  44. }
  45. public String toColorString(){
  46. String re=type+" ";
  47. for(int i=0;i<content.size();i++){
  48. re=re+content.get(i).toColorString();
  49. }
  50. re=re+"\n";
  51. return re;
  52. }
  53. }