Skip to content

Latest commit

 

History

History
155 lines (85 loc) · 2.96 KB

queue.md

File metadata and controls

155 lines (85 loc) · 2.96 KB

dastal - v5.0.0 / Queue

Interface: Queue<T>

An ordered collection of elements in FIFO (first-in-first-out) order (source).

Typically FIFO refers to the insertion order of elements. However, it can refer to other types of ordering. For example, priority queues order elements over the elements natural ordering (e.g. 2 before 4) or according to a given comparator. LIFO queues (e.g. stacks) order elements in last-in-first-out order.

Regardless, a call to dequeue() should return the first element relative to its order. Every implementation should specify its ordering properties. Otherwise, insertion order should be used.

Type parameters

Name
T

Hierarchy

Implemented by

Table of contents

Properties

Methods

Properties

size

Readonly size: number

The number of elements in the collection.

Inherited from

Collection.size

Defined in

src/collection/collection.ts:5

Methods

[iterator]

[iterator](): Iterator<T, any, undefined>

Returns

Iterator<T, any, undefined>

Inherited from

Collection.[iterator]

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:51


clear

clear(): void

Removes all elements.

Returns

void

Defined in

src/queue/queue.ts:19


dequeue

dequeue(): undefined | T

Retrieves and removes the head of this queue

Returns

undefined | T

The value at the head of the queue or undefined if this queue is empty.

Defined in

src/queue/queue.ts:25


enqueue

enqueue(element): number

Inserts the specified value into this queue

Parameters

Name Type Description
element T The element to be inserted

Returns

number

The new size of the queue

Defined in

src/queue/queue.ts:33


peek

peek(): undefined | T

Retrieves, but does not remove, the head of this queue

Returns

undefined | T

The value at the head of the queue or undefined if this queue is empty.

Defined in

src/queue/queue.ts:39