TreeArrayNode Interface
A TreeNode which implements 'readonly T[]' and the array mutation APIs.
This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.
Signature
/** @sealed */
export interface TreeArrayNode<TAllowedTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe = ImplicitAllowedTypes, out T = [TAllowedTypes] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TAllowedTypes> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>, in TNew = [TAllowedTypes] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes> : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T>
Extends: ReadonlyArrayNode<T>
Type Parameters
| Parameter | Constraint | Default | Description |
|---|---|---|---|
| TAllowedTypes | System_Unsafe.ImplicitAllowedTypesUnsafe | ImplicitAllowedTypes | Schema for types which are allowed as members of this array. |
| T | [TAllowedTypes] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TAllowedTypes> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes> | Use Default: Do not specify. Type of values to read from the array. | |
| TNew | [TAllowedTypes] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes> : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes> | Use Default: Do not specify. Type of values to write into the array. | |
| TMoveFrom | ReadonlyArrayNode | Use Default: Do not specify. Type of node from which children can be moved into this array. |
Methods
| Method | Return Type | Description |
|---|---|---|
| insertAt(index, value) | void | Inserts new item(s) at a specified location. |
| insertAtEnd(value) | void | Inserts new item(s) at the end of the array. |
| insertAtStart(value) | void | Inserts new item(s) at the start of the array. |
| moveRangeToEnd(sourceStart, sourceEnd) | void | Moves the specified items to the end of the array. |
| moveRangeToEnd(sourceStart, sourceEnd, source) | void | Moves the specified items to the end of the array. |
| moveRangeToIndex(destinationGap, sourceStart, sourceEnd) | void | Moves the specified items to the desired location within the array. WARNING - This API is easily misused. Please read the documentation for the |
| moveRangeToIndex(destinationGap, sourceStart, sourceEnd, source) | void | Moves the specified items to the desired location within the array. WARNING - This API is easily misused. Please read the documentation for the |
| moveRangeToStart(sourceStart, sourceEnd) | void | Moves the specified items to the start of the array. |
| moveRangeToStart(sourceStart, sourceEnd, source) | void | Moves the specified items to the start of the array. |
| moveToEnd(sourceIndex) | void | Moves the specified item to the end of the array. |
| moveToEnd(sourceIndex, source) | void | Moves the specified item to the end of the array. |
| moveToIndex(destinationGap, sourceIndex) | void | Moves the specified item to the desired location in the array. WARNING - This API is easily misused. Please read the documentation for the |
| moveToIndex(destinationGap, sourceIndex, source) | void | Moves the specified item to the desired location in the array. WARNING - This API is easily misused. Please read the documentation for the |
| moveToStart(sourceIndex) | void | Moves the specified item to the start of the array. |
| moveToStart(sourceIndex, source) | void | Moves the specified item to the start of the array. |
| push(value) | void | Inserts new item(s) at the end of the array. |
| removeAt(index) | void | Removes the item at the specified location. |
| removeRange(start, end) | void | Removes all items between the specified indices. |
| values() | IterableIterator<T> | Returns a custom IterableIterator which throws usage errors if concurrent editing and iteration occurs. |
Method Details
insertAt
Inserts new item(s) at a specified location.
Signature
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
Remarks
All items inserted by a single call to this method are inserted consecutively. The order of the inserted items relative to other concurrently inserted items at the same location is only partially specified: Concurrently inserting [A, B] and [X, Y] at the same location may yield either [A, B, X, Y] or [X, Y, A, B], regardless of the order in which those edits are sequenced. No other interleavings are possible. (e.g. [A, X, B, Y] is not possible.)
Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | The index at which to insert value. |
| value | readonly (TNew | IterableTreeArrayContent<TNew>)[] | The content to insert. |
Error Handling
Throws if index is not in the range [0, array.length).
insertAtEnd
Inserts new item(s) at the end of the array.
Signature
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
Remarks
Equivalent to insertAt(array.length, ...value): see insertAt(index, value) for details, including merge semantics with concurrent edits.
Parameters
| Parameter | Type | Description |
|---|---|---|
| value | readonly (TNew | IterableTreeArrayContent<TNew>)[] | The content to insert. |
insertAtStart
Inserts new item(s) at the start of the array.
Signature
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
Remarks
Equivalent to insertAt(0, ...value): see insertAt(index, value) for details, including merge semantics with concurrent edits.
Parameters
| Parameter | Type | Description |
|---|---|---|
| value | readonly (TNew | IterableTreeArrayContent<TNew>)[] | The content to insert. |
moveRangeToEnd
Moves the specified items to the end of the array.
Signature
moveRangeToEnd(sourceStart: number, sourceEnd: number): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| sourceStart | number | The starting index of the range to move (inclusive). |
| sourceEnd | number | The ending index of the range to move (exclusive) |
Error Handling
Throws if either of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd. if any of the input indices are not in the range [0, array.length], or if sourceStart is greater than sourceEnd.
moveRangeToEnd
Moves the specified items to the end of the array.
Signature
moveRangeToEnd(sourceStart: number, sourceEnd: number, source: TMoveFrom): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| sourceStart | number | The starting index of the range to move (inclusive). |
| sourceEnd | number | The ending index of the range to move (exclusive) |
| source | TMoveFrom | The source array to move items out of. |
Error Handling
Throws if the types of any of the items being moved are not allowed in the destination array, if either of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd. if any of the input indices are not in the range [0, array.length], or if sourceStart is greater than sourceEnd.
moveRangeToIndex
Moves the specified items to the desired location within the array.
WARNING - This API is easily misused. Please read the documentation for the destinationGap parameter carefully.
Signature
moveRangeToIndex(destinationGap: number, sourceStart: number, sourceEnd: number): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| destinationGap | number | The location *between* existing items that the moved item should be moved to. WARNING - For example, if the array contains items
So moving This interpretation of
This interpretation of
Notice the asymmetry between |
| sourceStart | number | The starting index of the range to move (inclusive). |
| sourceEnd | number | The ending index of the range to move (exclusive) |
Error Handling
Throws if any of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd. if any of the input indices are not in the range [0, array.length], or if sourceStart is greater than sourceEnd.
moveRangeToIndex
Moves the specified items to the desired location within the array.
WARNING - This API is easily misused. Please read the documentation for the destinationGap parameter carefully.
Signature
moveRangeToIndex(destinationGap: number, sourceStart: number, sourceEnd: number, source: TMoveFrom): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| destinationGap | number | The location *between* existing items that the moved item should be moved to. WARNING - For example, if the array contains items
So moving This interpretation of
This interpretation of
Notice the asymmetry between |
| sourceStart | number | The starting index of the range to move (inclusive). |
| sourceEnd | number | The ending index of the range to move (exclusive) |
| source | TMoveFrom | The source array to move items out of. |
Error Handling
Throws if the types of any of the items being moved are not allowed in the destination array, if any of the input indices are not in the range [0, array.length], or if sourceStart is greater than sourceEnd.