JPP: Small fixes in collection2 to think abount X0 naming
All checks were successful
Run test asserts / Test-Asserts (push) Successful in 1m4s

This commit is contained in:
Willem Cazander 2026-02-03 11:08:20 +01:00
parent b8855069df
commit 1a29d40fce
11 changed files with 229 additions and 189 deletions

View file

@ -43,15 +43,34 @@ public interface Ladder<E> extends Yarn<E> {
}
default E get(long index) {
return stream().skip(index).collect(Collectors.toList()).get(0);
return stream().skip(index).findFirst().get();
}
default int indexOf(Object o) {
return stream().collect(Collectors.toList()).indexOf(o);
// TODO: replace all "long" with ~ZerdinalX63 (extends ZerdinalX0<Long>)
default long indexOf(Object obj) {
long ladderSize = size();
for (long i = 0; i < ladderSize; i++) {
E v = get(i);
if (v == null && obj == null) {
return i;
}
if (v != null && v.equals(obj)) {
return i;
}
}
return -1L;
}
default int lastIndexOf(Object o) {
return stream().collect(Collectors.toList()).lastIndexOf(o);
default long lastIndexOf(Object obj) {
long lastIdx = -1L;
long currIdx = 0L;
while (currIdx != -1L) {
currIdx = indexOf(obj);
if (currIdx != -1L) {
lastIdx = currIdx;
}
}
return lastIdx;
}
default RopeLadder<E> ropeLadder() {