Improve task ordering algorithms

This commit is contained in:
2020-05-02 19:18:54 +03:00
parent d7809818ea
commit 04205ba21a
2 changed files with 47 additions and 26 deletions

View File

@ -34,10 +34,12 @@ export class TaskQueue {
return matched.length > 0;
}
modify(predicate: (t: Task) => boolean, modifier: (t: Task) => Task) {
modify(predicate: (t: Task) => boolean, modifier: (t: Task) => Task): number {
const [matched, other] = this.split(predicate);
const modified = matched.map(modifier);
const modifiedCount = modified.length;
this.flushItems(modified.concat(other));
return modifiedCount;
}
remove(id: TaskId) {