1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
java2js/jre/java/util/Itr.js
Quinton Ashley fcf49e5a8d 1.0.1
2021-09-23 01:41:44 -05:00

33 lines
557 B
JavaScript
Executable File

jre.imports['java.util.Itr'].load = () => {
class Itr {
constructor(list) {
this.cursor = 0;
this.lastRet = -1;
this.list = list;
}
hasNext() {
return this.cursor != this.list.size();
}
next() {
try {
const i = this.cursor;
const next = this.list.get(i);
this.lastRet = i;
this.cursor = i + 1;
return next;
} catch ($ex$) {
if ($ex$ instanceof Error) {
const e = $ex$;
throw new Error("no such element exception");
} else {
throw $ex$;
}
}
}
}
jre.java.util.Itr = Itr;
}