File size: 360 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
export default class SimpleSet {
constructor() {
this.v = [];
}
clear() {
this.v.length = 0;
}
has(k) {
return this.v.indexOf(k) !== -1;
}
add(k) {
if (this.has(k)) return;
this.v.push(k);
}
delete(k) {
const idx = this.v.indexOf(k);
if (idx === -1) return false;
this.v.splice(idx, 1);
return true;
}
}
|