1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
java2js/jdk/java/util/Itr.js
Quinton Ashley 159919e856 1.0.4
2021-09-24 00:36:29 -05:00

32 lines
563 B
JavaScript
Executable File

jdk.imports['java.util.Itr'].load = async () => {
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$;
}
}
}
}
jdk.java.util.Itr = Itr;
};