mirror of
https://github.com/quinton-ashley/java2js
synced 2024-12-29 10:11:54 +01:00
74 lines
1.1 KiB
JavaScript
Executable File
74 lines
1.1 KiB
JavaScript
Executable File
jre.imports['java.util.HashSet'].load = () => {
|
|
|
|
class HashSet {
|
|
constructor() {
|
|
this.content = {};
|
|
}
|
|
|
|
add(val) {
|
|
this.content[val] = val;
|
|
}
|
|
|
|
clear() {
|
|
this.content = {};
|
|
}
|
|
|
|
contains(val) {
|
|
return this.content.hasOwnProperty(val);
|
|
}
|
|
|
|
containsAll(elems) {
|
|
return false;
|
|
}
|
|
|
|
addAll(vals) {
|
|
const tempArray = vals.toArray(null);
|
|
for (let i = 0; i < tempArray.length; i++) {
|
|
this.content[tempArray[i]] = tempArray[i];
|
|
}
|
|
return true;
|
|
}
|
|
|
|
remove(val) {
|
|
let b = false;
|
|
if (this.content[val]) {
|
|
b = true;
|
|
}
|
|
delete this.content[val];
|
|
return b;
|
|
}
|
|
|
|
removeAll() {
|
|
return false;
|
|
}
|
|
|
|
size() {
|
|
return Object.keys(this.content).length;
|
|
}
|
|
|
|
isEmpty() {
|
|
return this.size() == 0;
|
|
}
|
|
|
|
toArray(a) {
|
|
const _this = this;
|
|
return Object.keys(this.content).map(key => _this.content[key]);
|
|
}
|
|
|
|
iterator() {
|
|
return new java.util.Itr(this);
|
|
}
|
|
|
|
forEach(f) {
|
|
for (const p in this.content) {
|
|
f(this.content[p]);
|
|
}
|
|
}
|
|
|
|
get(index) {
|
|
return this.content[index];
|
|
}
|
|
}
|
|
jre.java.util.HashSet = HashSet;
|
|
}
|