/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{Evented as e}from"../../../core/Evented.js";import{signal as t}from"../../../core/signal.js";class s extends e{constructor(){super(...arguments),this._set=new Set,this._length=t(0)}clear(){if(this._set.size>0){const e=this.toArray();this._set.clear(),this.emit("after-changes",{type:2}),this.emit("change",{added:[],removed:e})}}get length(){return this._length.value}addMany(e){if(0!==e.length){for(const t of e)this._set.add(t);this._length.value=this._set.size,this.emit("after-changes",{type:1}),this.emit("change",{added:e,removed:[]})}}remove(e){this._set.delete(e)&&(this._length.value=this._set.size,this.emit("after-changes",{type:2}),this.emit("change",{added:[],removed:[e]}))}removeMany(e){const t=[];for(const s of e)this._set.delete(s)&&t.push(s);t.length>0&&(this._length.value=this._set.size,this.emit("after-changes",{type:2}),this.emit("change",{added:[],removed:t}))}toArray(){return Array.from(this._set.values())}find(e){for(const t of this._set.values())if(e(t))return t}some(e){for(const t of this._set.values())if(e(t))return!0;return!1}forEach(e){this._set.forEach(t=>e(t))}}export{s as EventedSet};
