class SPPCounter {

	public synchronized Iterator<Long> increment(final int delta) {
		final long old = counter;
		counter = (counter + delta) % wrap;

		// No synchronization of the Iterator methods because it should only be accessed from a
		// single thread.
		return new Iterator<Long>() {
			private long c = old;
			private int d = delta;

			@Override
			public boolean hasNext() {
				return d > 0;
			}

			@Override
			public Long next() {
				if (!hasNext()) {
					throw new NoSuchElementException();
				}
				d--;
				c = (c + 1) % wrap;
				return c;
			}

			@Override
			public void remove() {
				throw new UnsupportedOperationException("Not supported.");
			}
		};
	}

	public  SPPCounter(final long wrap);

}