LoopedArray<T>

Guide: /guide/data-structures/looped-array

Generic Types

T - type of collection elements

Implements interfaces

IArrayFacade

ILinearStorage

ILinearStorageRA

Methods

constructor(capacity: number): IArrayFacade<T>

Creates empty instance

Params:
NameTypeRequiredDefaultDescription
capacitynumber+-Max capacity of array
(> 0)
Throws: ValueOutOfRangeException when given capacity is out of range



peek(): T

Returns value from top of array



pop(): T

Removes item from array end (head element) and returns its value

Throws: CollectionIsEmptyException when array is empty



push(value: T): void

Add value to top of array

Params:
NameTypeRequiredDefaultDescription
valueT+-



has(value: T): boolean

Check is array has given value

Params:
NameTypeRequiredDefaultDescription
valueT+-



peekFromStart(): T

Get first element of array



peekByIndex(index: number): T

Get element by given index from array start

Params:
NameTypeRequiredDefaultDescription
indexnumber+-0 <= index <= array.length - 1



unshift(value: T): void

Add new node into array start

Params:
NameTypeRequiredDefaultDescription
valueT+-



pushFromIndex(value: T, fromIndex: number): void

Add new node into array by index

Params:
NameTypeRequiredDefaultDescription
valueT+-
fromIndexnumber+-0 <= index <= array.length - 1



shift(): T

Remove node from array start and get its value

Throws: CollectionIsEmptyException when array is empty



deleteFromIndex(fromIndex: number): T

Remove node from array by index

Params:
NameTypeRequiredDefaultDescription
fromIndexnumber+-0 <= index <= array.length - 1



pushFromArray(elements: Array<T>): void

Add elements from array collection in order from start

Params:
NameTypeRequiredDefaultDescription
elementsArray<T>+-



getAsArray(): Array<T>

Convert linked array into array collection in order from start

Params:
NameTypeRequiredDefaultDescription
elementsArray<T>+-



clear(): void

Remove all elements from array



isEmpty(): boolean

Check is array has any value, returns true if array is empty



isFull(): boolean

Check is array length exceed max capacity



length(): number

Get array size