dastal - v5.0.0 / SortedTree
Represents a sorted tree data structure.
Name |
---|
T |
• Readonly
size: number
The number of elements in the collection.
src/collection/collection.ts:5
▸ [iterator](): Iterator
<T, any, undefined>
Iterator
<T, any, undefined>
node_modules/typescript/lib/lib.es2015.iterable.d.ts:51
▸ add(element
): SortedTree<T>
Inserts an element into the tree.
Name | Type | Description |
---|---|---|
element |
T |
The element to be inserted. |
SortedTree<T>
The tree object.
▸ clear(): void
Removes all elements.
void
▸ comparator(): CompareFn<T>
CompareFn<T>
The function with which elements are sorted
▸ delete(element
): boolean
Delete an element from the tree.
Name | Type | Description |
---|---|---|
element |
T |
The element to delete. |
boolean
true
if the element was found and deleted, otherwise false
.
▸ has(element
): boolean
Check if an element is in the tree.
Name | Type | Description |
---|---|---|
element |
T |
The element to find. |
boolean
true
if the element was found, otherwise false
.
▸ max(): undefined
| T
Get the maximum element.
undefined
| T
▸ min(): undefined
| T
Get the minimum element.
undefined
| T
▸ pop(): undefined
| T
Remove the maximum element.
undefined
| T
▸ shift(): undefined
| T
Remove the minimum element.
undefined
| T
▸ 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.
Iterable
<T>
▸ update(curElement
, newElement
): boolean
Update a specific element.
Name | Type | Description |
---|---|---|
curElement |
T |
The element to update. |
newElement |
T |
The new element to insert. |
boolean
true
if curElement was found and updated, otherwise false
.