(https://github.com/Salakar) Fast, well-tested double-ended queue implementation based on ring buffer
This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/559642/1733950/Denque-on-Greasy-Fork.js
This is Mike Diarmid's Denque class. https://github.com/Salakar — copyright © 2018 Invertase Limited https://github.com/invertase/denque
Automatically repackaged here for userscripts, instead of the original packaging as a CommonJS module for Node.js. See Github for details of the automated workflow.
From the Github homepage at https://github.com/invertase/denque:
Denque is a well tested, extremely fast and lightweight double-ended queue implementation with zero dependencies and includes TypeScript types.
This implementation is currently the fastest available, even faster than double-ended-queue, see the benchmarks.
Every queue operation is done at a constant O(1) - including random access from
.peekAt(index).
To use:
const Deque = getDenqueClass();
const myDoubleEndedQueue = new Deque();
The instance returned by new will have all the usual methods of a deque (pronounced "deck" like a deck of cards): push, pop, unshift, shift, isEmpty, and so on. See the Denque code for documentation.