maven compiles all tests independetly of which tests are run
This commit is contained in:
35
src/main/java/oving5/stringgrid/StringGridIterator.java
Normal file
35
src/main/java/oving5/stringgrid/StringGridIterator.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package oving5.stringgrid;
|
||||
|
||||
public class StringGridIterator {
|
||||
private StringGrid grid;
|
||||
private boolean rowMajor;
|
||||
private int i = -1;
|
||||
|
||||
public StringGridIterator(StringGrid grid, boolean rowMajor) {
|
||||
this.grid = grid;
|
||||
this.rowMajor = rowMajor;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return (i + 1) < (grid.getRowCount() * grid.getColumnCount());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String next() {
|
||||
if (hasNext()) {
|
||||
i += 1;
|
||||
if (rowMajor) {
|
||||
return grid.getElement(i / grid.getColumnCount(), i % grid.getColumnCount());
|
||||
} else {
|
||||
return grid.getElement(i % grid.getRowCount(), i / grid.getRowCount());
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user