@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
2 lines (1 loc) • 582 B
JavaScript
class i{constructor(){this._list=[],this._index={}}push(i,t){if(this._index[i])throw Error(`Key already in index ${i}`);const s=this._list.push(t)-1;this._index[i]=s}has(i){return void 0!==this._index[i]}get(i){const t=this._index[i];return void 0!==t?this._list[t]:null}remove(i){const t=this._index[i];if(void 0!==t){for(i in this._list.splice(t,1),delete this._index[i],this._index){const s=this._index[i];s>t&&(this._index[i]=s-1)}return!0}return!1}list(){return this._list}clear(){this._list.length=0;for(const i in this._index)delete this._index[i]}}export{i as IndexedList};