Denque-on-Greasy-Fork

(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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Author
JasonMel
Version
2.1.0h
Created
2025-12-20
Updated
2025-12-27
Size
29.8 KB
License
Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)

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.