Skip to content

Latest commit

 

History

History
184 lines (100 loc) · 3.88 KB

File metadata and controls

184 lines (100 loc) · 3.88 KB

dangraph / Exports / utils/danStack / DanStack

Class: DanStack<T>

utils/danStack.DanStack

DanStack is a simple class implementing Stackable interface

Type parameters

Name
T

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DanStack<T>(): DanStack<T>

The public class constructor

Type parameters

Name
T

Returns

DanStack<T>

Defined in

src/utils/danStack.ts:26

Properties

_list

Private _list: T[]

Defined in

src/utils/danStack.ts:21

Methods

clear

clear(): void

Clear all stack's elements We use the 'splice' method of the private member '_list'

Returns

void

Implementation of

Stackable.clear

Defined in

src/utils/danStack.ts:73


isEmpty

isEmpty(): boolean

Check if the stack is empty We use the 'length' method of the private member '_list' to check the number of elements present: if the number is less than 1, the stack is empty

Returns

boolean

true if the stack is empty; it returns false is the stack is not empty

Implementation of

Stackable.isEmpty

Defined in

src/utils/danStack.ts:65


peek

peek(): undefined | T

Get the value from the top of the stack but do not remove it from the stack itself

Returns

undefined | T

the element on top of the stack if the stack is not empty; conversely it returns undefined

Implementation of

Stackable.peek

Defined in

src/utils/danStack.ts:52


pop

pop(): undefined | T

Get the value from the top of the stack and remove it from the stack itself We use the 'pop' method of the private member '_list'

Returns

undefined | T

the element on top of the stack if the stack is not empty; conversely it returns undefined

Implementation of

Stackable.pop

Defined in

src/utils/danStack.ts:44


push

push(val): void

Insert a value to the top of the stack We use the 'push' method of the private member '_list'

Parameters

Name Type Description
val T the value to be pushed inside the stack

Returns

void

Implementation of

Stackable.push

Defined in

src/utils/danStack.ts:35