I have the code:
This code is for an insertion sort algorithm, which I want to visualize. I want to use my updateList() method to update my list of blocks to show what happens each step. Each step would be after one part of the nested for loop. Since this algorithm is under act, it occurs in one act step. Is it possible to change my list using updateList() every step of my sorting algorithm?
public void act() { //on first act, get blocklist, size, and initialize positionZ int if (size <= 0) { list = ((SortingVisualization)getWorld()).getBlockList(); size = list.size(); } else if (size > 0) { Block temp; for (int i=0; i<size; i++) { for (int j=i; j>0; j--) { if (((Block)list.get(j)).getValue() < ((Block)list.get(j-1)).getValue()) { temp = (Block)list.get(j); list.set(j, (Block)list.get(j-1)); list.set(j-1, temp); updateList(); } } } } }