org.psjava.ds.array.MutableSubArray 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
package org.psjava.ds.array;
import java.util.Iterator;
import org.psjava.util.IterableToString;
public class MutableSubArray {
// TODO impl equals
public static MutableArray wrap(final MutableArray original, final int start, final int end) {
return new MutableArray() {
@Override
public T get(int index) {
return original.get(start + index);
}
@Override
public void set(int index, T value) {
original.set(start + index, value);
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public Iterator iterator() {
return ArrayIterator.create(this);
}
@Override
public int size() {
return end - start;
}
@Override
public String toString() {
return IterableToString.toString(this);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy