mirror of
https://github.com/quinton-ashley/java2js
synced 2024-12-29 10:11:54 +01:00
32 lines
563 B
JavaScript
Executable File
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;
|
|
};
|