Skip to content

Instantly share code, notes, and snippets.

@Phryxia
Phryxia / CircularQueue.js
Last active January 13, 2026 20:42
Simple CircularQueue implementation for JavaScript/TypeScript
class CircularQueue {
/**
* @param {number} growthRate Rate of growth when additional allocation is required. It must be larger than 1.
*/
constructor(growthRate) {
this.growthRate = growthRate
this.data = new Array(4);
this.head = 0;
this.tail = 0;
this.size = 0;