package org.psjava.util;

import java.util.Iterator;

public class IntSequenceIterator {

	public static Iterator<Integer> create(final int start, final int step, final int size) {
		return new ReadOnlyIterator<Integer>() {
			int nextIndex = 0;

			@Override
			public boolean hasNext() {
				return nextIndex < size;
			}

			@Override
			public Integer next() {
				return start + step * (nextIndex++);
			}
		};
	}

	private IntSequenceIterator() {
	}

}

@@ -181,16 +181,61 @@
 ize) %7B%0D%0A
+%09%09final int last = start + step * (size-1);%0D%0A
 %09%09return
@@ -285,17 +285,16 @@
 next
-Index = 0
+ = start
 ;%0D%0A%0D
@@ -358,20 +358,16 @@
 next
-Index %3C size
+ %3C= last
 ;%0D%0A%09
@@ -423,43 +423,54 @@
 %09%09%09%09
-return star
+int r = next;%0D%0A%09%09%09%09nex
 t +
+=
  step
- * (nextIndex++)
+;%0D%0A%09%09%09%09return r
 ;%0D%0A%09

improve performance of IntSequenceIterator