Skip to content

Latest commit

 

History

History
314 lines (169 loc) · 5.17 KB

sortedtree.md

File metadata and controls

314 lines (169 loc) · 5.17 KB

dastal - v5.0.0 / SortedTree

Interface: SortedTree<T>

Represents a sorted tree data structure.

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

Tree.size

Defined in

src/collection/collection.ts:5

Methods

[iterator]

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

Returns

Iterator<T, any, undefined>

Inherited from

Tree.[iterator]

Defined in

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


add

add(element): SortedTree<T>

Inserts an element into the tree.

Parameters

Name Type Description
element T The element to be inserted.

Returns

SortedTree<T>

The tree object.

Inherited from

Tree.add

Defined in

src/tree/tree.ts:38


clear

clear(): void

Removes all elements.

Returns

void

Inherited from

Tree.clear

Defined in

src/tree/tree.ts:42


comparator

comparator(): CompareFn<T>

Returns

CompareFn<T>

The function with which elements are sorted

Inherited from

Sorted.comparator

Defined in

src/index.ts:61


delete

delete(element): boolean

Delete an element from the tree.

Parameters

Name Type Description
element T The element to delete.

Returns

boolean

true if the element was found and deleted, otherwise false.

Inherited from

Tree.delete

Defined in

src/tree/tree.ts:50


has

has(element): boolean

Check if an element is in the tree.

Parameters

Name Type Description
element T The element to find.

Returns

boolean

true if the element was found, otherwise false.

Inherited from

Tree.has

Defined in

src/tree/tree.ts:58


max

max(): undefined | T

Get the maximum element.

Returns

undefined | T

Defined in

src/tree/sortedTree.ts:11


min

min(): undefined | T

Get the minimum element.

Returns

undefined | T

Defined in

src/tree/sortedTree.ts:15


pop

pop(): undefined | T

Remove the maximum element.

Returns

undefined | T

Defined in

src/tree/sortedTree.ts:19


shift

shift(): undefined | T

Remove the minimum element.

Returns

undefined | T

Defined in

src/tree/sortedTree.ts:23


sorted

sorted(): Iterable<T>

Iterate through the tree in sorted order (i.e in-order traversal).

Note: Unexpected behavior can occur if the collection is modified during iteration.

Returns

Iterable<T>

Defined in

src/tree/sortedTree.ts:29


update

update(curElement, newElement): boolean

Update a specific element.

Parameters

Name Type Description
curElement T The element to update.
newElement T The new element to insert.

Returns

boolean

true if curElement was found and updated, otherwise false.

Inherited from

Tree.update

Defined in

src/tree/tree.ts:67