org.psjava.ds.array.RotatedArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of psjava Show documentation
Show all versions of psjava Show documentation
Problem Solving Library for Java
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