Skip to content

Latest commit

 

History

History
153 lines (83 loc) · 2.75 KB

stack.md

File metadata and controls

153 lines (83 loc) · 2.75 KB

dastal - v5.0.0 / Stack

Interface: Stack<T>

An ordered collection of elements in LIFO (last-in-first-out) order.

Typically LIFO refers to the insertion order of elements. However, it can refer to other types of ordering via a different implementation or a given comparator. FIFO stacks (e.g. queues) order elements in first-in-first-out order.

Regardless, a call to pop() should return the last 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/stack/stack.ts:17


peek

peek(): undefined | T

Retrieves, but does not remove, the top of the stack

Returns

undefined | T

The element at the top of the stack or undefined if empty.

Defined in

src/stack/stack.ts:23


pop

pop(): undefined | T

Retrieves and removes the top of the stack

Returns

undefined | T

The element at the top of the stack or undefined if empty.

Defined in

src/stack/stack.ts:29


push

push(element): number

Inserts an element into the stack

Parameters

Name Type Description
element T The element to be inserted

Returns

number

The new size of the stack

Defined in

src/stack/stack.ts:37