Skip to content

make PriorityQueue array protected rather than private #140

@trajano

Description

@trajano

This will allow us to extend the existing priority queue to make methods that change to the underlying structure for example "remove" to remove entries from the promise queue for scenarios like an image component getting unmounted so there's no point in keeping the promise of downloading the image.

Right now I am copying the class and adding the new method

  removeWithPredicate(predicate: (entry: PriorityQueueOptions & { run: RunFunction }) => boolean): void {
    let i, j;

    for (i = 0, j = 0; i < this._queue.length; ++i) {
      if (predicate(this._queue[i])) {
        this._queue[j] = this._queue[i];
        ++j;
      }
    }

    while (j < this._queue.length) {
      this._queue.pop();
    }
  }
  

based off https://stackoverflow.com/a/54270177/242042

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions