Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/fathym_common/src/common/iterables/Queue.ts>Queue

The Fathym Reference Architecture provides the common foundation for applications built in Typescript.
Latest
class Queue
import { Queue } from "https://deno.land/x/fathym_common@v0.2.160/src/common/iterables/Queue.ts";

This is a simple implementation of a queue data structure.

Examples

From direct import

import { Queue } from "@fathym/common/iterables";

const queue = new Queue<number>();

queue.Enqueue(1);

queue.Enqueue(2);

queue.Dequeue(); // Output: 1

queue.Peek(); // Output: 2

queue.Dequeue(); // Output: 2

queue.IsEmpty(); // Output: true

From common import

import { Queue } from "@fathym/common";

const queue = new Queue<number>();

queue.Enqueue(1); // Output: 1

queue.Enqueue(2); // Output: 2

queue.Dequeue(); // Output: 1

queue.Dequeue(); // Output: 2

Constructors

new
Queue()

Properties

private
items: T[]

Methods

Dequeue(): T | undefined

Used to remove and return the item at the front of the queue.

Enqueue(item: T): void

Used to add an item to the end of the queue.

IsEmpty(): boolean

Used to check if the queue is empty.

Peek(): T | undefined

Used to return the item at the front of the queue without removing it.

Size(): number

Used to get the number of items in the queue.