This repository has been archived on 2025-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
aud-2021-exam-prep/src/aud/exam/prep/array/FullyUsedArrayProcessor.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);
}
}