Skip to content

Latest commit

 

History

History
331 lines (182 loc) · 6.68 KB

Queue.md

File metadata and controls

331 lines (182 loc) · 6.68 KB

circle-ds / Exports / Queue

Interface: Queue<V>

Represents a queue collection of elements. A queue allows elements to be added to the end and removed from the front, adhering to the FIFO (First In, First Out) principle. This interface extends the Collection interface and specifies additional queue-specific operations.

Queues are commonly used in scenarios where you need to process elements in the order they were added, such as task scheduling, buffering data streams, and breadth-first graph traversal.

Type parameters

Name
V

Hierarchy

Implemented by

Table of contents

Accessors

Methods

Accessors

[toStringTag]

get [toStringTag](): string

A string tag for the Collection class that is used in Object.prototype.toString.

Returns

string

Inherited from

Collection.[toStringTag]

Defined in

types/collection.d.ts:19


size

get size(): number

Gets the number of elements contained in the Collection.

Returns

number

Inherited from

Collection.size

Defined in

types/collection.d.ts:14

Methods

[iterator]

[iterator](): IterableIterator<V>

Returns the default iterator through the queue's elements.

Returns

IterableIterator<V>

Defined in

types/queue.d.ts:61


clear

clear(): void

Removes all elements from the Collection, effectively resetting it.

Returns

void

Inherited from

Collection.clear

Defined in

types/collection.d.ts:24


entries

entries(): IterableIterator<[number, V]>

Returns a new iterator object that contains an array of [key, value] pairs for each element in the Collection.

Returns

IterableIterator<[number, V]>

An iterable iterator for the entries of the collection.

Inherited from

Collection.entries

Defined in

types/collection.d.ts:32


first

first(): undefined | V

Retrieves the first element added to the queue without removing it.

Returns

undefined | V

The first element of the queue, or undefined if the queue is empty.

Defined in

types/queue.d.ts:19


forEach

forEach(callbackfn, thisArg?): void

Executes a provided function once for each key-value pair in the Collection.

Parameters

Name Type Description
callbackfn (value: V, key: number, collection: this) => void A function to execute for each element, receiving the value, key, and collection instance as arguments.
thisArg? unknown An optional value to use as this when executing callbackfn.

Returns

void

Inherited from

Collection.forEach

Defined in

types/collection.d.ts:41


front

front(): undefined | V

Retrieves the element at the front of the queue without removing it.

This method provides semantic clarity in contexts where the term "front" is preferred over "first" to describe the element that was added earliest and will be processed next.

Returns

undefined | V

The element at the front of the queue, or undefined if the queue is empty.

Defined in

types/queue.d.ts:30


has

has(value): boolean

Determines whether a specific element exists within the queue.

Parameters

Name Type Description
value V The value to locate.

Returns

boolean

true if the value exists, false otherwise.

Defined in

types/queue.d.ts:39


keys

keys(): IterableIterator<number>

Returns a new iterator that contains the keys for each element in the Collection.

Returns

IterableIterator<number>

An iterable iterator for the keys of the collection.

Inherited from

Collection.keys

Defined in

types/collection.d.ts:52


push

push(...values): number

Adds one or more elements to the end of the queue and returns the queue's new length.

Parameters

Name Type Description
...values V[] The elements to add.

Returns

number

The new length of the queue.

Defined in

types/queue.d.ts:49


shift

shift(): undefined | V

Removes and returns the first element of the queue.

Returns

undefined | V

The first element of the queue, or undefined if the queue is empty.

Defined in

types/queue.d.ts:56


values

values(): IterableIterator<V>

Returns a new iterator that contains the values for each element in the Collection.

Returns

IterableIterator<V>

An iterable iterator for the values of the collection.

Inherited from

Collection.values

Defined in

types/collection.d.ts:60