mirror of
https://github.com/quinton-ashley/java2js
synced 2024-12-29 10:11:54 +01:00
61 lines
1.0 KiB
JavaScript
Executable File
61 lines
1.0 KiB
JavaScript
Executable File
jdk.imports['java.util.HashMap'].load = async () => {
|
|
class HashMap {
|
|
constructor() {
|
|
this.content = {};
|
|
}
|
|
|
|
get(key) {
|
|
return this.content[key];
|
|
}
|
|
|
|
put(key, value) {
|
|
const previous_val = this.content[key];
|
|
this.content[key] = value;
|
|
return previous_val;
|
|
}
|
|
|
|
containsKey(key) {
|
|
return this.content.hasOwnProperty(key);
|
|
}
|
|
|
|
remove(key) {
|
|
const tmp = this.content[key];
|
|
delete this.content[key];
|
|
return tmp;
|
|
}
|
|
|
|
keySet() {
|
|
const result = new HashSet();
|
|
for (const p in this.content) {
|
|
if (this.content.hasOwnProperty(p)) {
|
|
result.add(p);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
isEmpty() {
|
|
return Object.keys(this.content).length == 0;
|
|
}
|
|
|
|
values() {
|
|
const result = new HashSet();
|
|
for (const p in this.content) {
|
|
if (this.content.hasOwnProperty(p)) {
|
|
result.add(this.content[p]);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
clear() {
|
|
this.content = {};
|
|
}
|
|
|
|
size() {
|
|
return Object.keys(this.content).length;
|
|
}
|
|
}
|
|
jdk.java.util.HashMap = HashMap;
|
|
};
|