ern-api-gen
Version:
Electrode Native API generator
85 lines • 1.94 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class FakeHashSet {
constructor(...arr) {
this.value = [];
this.addAll(arr);
}
add(v) {
if (this.contains(v)) {
return false;
}
this.value.push(v);
return true;
}
addAll(all) {
let result = true;
for (const v of all) {
const ret = this.add(v);
if (!ret) {
result = false;
}
}
return result;
}
clear() {
this.value = [];
}
remove(v) {
const idx = this.value.indexOf(v);
if (idx > -1) {
this.value.splice(idx, 1);
return true;
}
return false;
}
removeAll(c) {
let result = true;
for (const v of c) {
const ret = this.remove(v);
if (!ret) {
result = false;
}
}
return result;
}
contains(v) {
return this.value.indexOf(v) > -1;
}
get size() {
return this.value.length;
}
get length() {
return this.value.length;
}
isEmpty() {
return this.value.length === 0;
}
[Symbol.iterator]() {
return this.value[Symbol.iterator]();
}
// Java Like iterator different than Symbol.iterator.
iterator() {
const itr = this.value[Symbol.iterator]();
let c = itr.next();
return {
next() {
const value = c.value;
c = itr.next();
return value;
},
hasNext() {
return !c.done;
},
};
}
toArray() {
return this.value;
}
toJSON() {
return this.value;
}
}
exports.FakeHashSet = FakeHashSet;
exports.fakeSet = (...arr) => new FakeHashSet(...arr);
//# sourceMappingURL=FakeHashSet.js.map