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

org.psjava.ds.array.RotatedArray Maven / Gradle / Ivy

The newest version!
package org.psjava.ds.array;

import org.psjava.util.IterableToString;

import java.util.Iterator;

public class RotatedArray {
	public static  Array wrap(final Array array, final int startIndex) {
		return new Array() {
			@Override
			public T get(int index) {
				return array.get((startIndex + index) % array.size());
			}

			@Override
			public int size() {
				return array.size();
			}

			@Override
			public boolean isEmpty() {
				return array.isEmpty();
			}

			@Override
			public Iterator iterator() {
				return ArrayIterator.create(this);
			}

			@Override
			public String toString() {
				return IterableToString.toString(this);
			}
		};
	}

	private RotatedArray() {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy