/** * Simple implementation of circular shifting using two for loops. * * @author Alexander Schaap * */ public class CircularShifter extends CircularShifterAbstract { /** * Simple implementation of circular shifting using two for loops over 2D * array setting one cell at the time. The first line could just have been * copied. */ @Override public StorageInterface>> circularShifts( StorageInterface> line) { StorageInterface>> result = new StorageObservableArrayList>>(); for (int i = 0; i < line.length(); i++) { result.add(new StorageObservableArrayList>()); for (int j = 0; j < line.length(); j++) { result.get(i).add(line.get((j + i) % line.length())); } } return result; } }