27 lines
685 B
Java
27 lines
685 B
Java
package aud.exam.prep.array;
|
|
|
|
import aud.exam.prep.SequenceProcessor;
|
|
|
|
abstract class FullyUsedArrayProcessor<T> implements SequenceProcessor<T, FullyUsedArray<T>> {
|
|
|
|
@Override
|
|
public boolean overrideAt(FullyUsedArray<T> array, T to, int index) {
|
|
if (index < 0 || index >= array.theArray.length) {
|
|
return false;
|
|
}
|
|
|
|
array.theArray[index] = to;
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean check(FullyUsedArray<T> array) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public Iterable<T> iterate(FullyUsedArray<T> array) {
|
|
return () ->
|
|
new ArrayIterator<>(array.theArray, 0, array.theArray.length);
|
|
}
|
|
}
|