All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.lakis.cerebro.collections.loop.CustomIntegerArrayLoop Maven / Gradle / Ivy

Go to download

A framework to handle dependency injection and allowing users to communicate with the application using command line.

The newest version!
package net.lakis.cerebro.collections.loop;

import java.util.Iterator;

public class CustomIntegerArrayLoop implements Iterable {
	private int idx;
	private int size;

	private int[] array;
	private int start;

	public CustomIntegerArrayLoop(int[] array, int start) {
		this.idx = 0;
		this.array = array;

		if (array != null)
			this.size = array.length;
		
		if (size > 0)
			this.start = (start & 0x7FFFFFFF) % size;
	}

	@Override
	public Iterator iterator() {
		return new Iterator() {

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

			@Override
			public Integer next() {
				return array[(start + idx++) % size];
			}
		};
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy