Home Reference Source

src/renderer/GPURenderer/common/stores/UniqueList.js

/**
 * Map of particle IDs to integer ids
 */
export class UniqueList {
  constructor(max = Infinity) {
    this.max = max;
    this.count = 0;
    this._items = {};
  }

  add(item) {
    if (this._items[item] !== undefined) {
      return;
    }

    this._items[item] = this.count++;
  }

  find(item) {
    return this._items[item];
  }

  destroy() {
    this._items = {};
    this.count = 0;
  }
}