Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double[][] data;
- public Iterator<double> iterator() {
- return new FishIterator(data);
- }
- private class FishIterator<double> implements Iterator<double> {
- private int x = 0, xm, y = 0, ym
- public FishIterator(double[][] data) {
- xm = data.length;
- ym = data[0].length;
- }
- public boolean hasNext() {
- return !(y == ym-1 && x == xm-1);
- }
- public double next() {
- if (++x >= xm) {
- x = 0;
- y++;
- return data[x][y];
- }
- }
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
Add Comment
Please, Sign In to add comment