_insert MethodProtected
Attempts to insert a new value into the array at a position determined by the ordering. The behavior differs based on the array's DuplicatePolicy: If duplicates are not permitted, then:
- If an equivalent element already exists in the array:
- DuplicatePolicy.Retain: nothing will be inserted and the index of the existing element will be returned.
- Replace: the input value will overwrite the existing element at the same index and that index will be returned.
- Otherwise, the element is inserted and its index is returned. If duplicates are permitted, then:
- The element will be inserted in a correct position based on the sorting criterion;
- The position of the element relative to other elements comparing as equal to it is unspecified; and
- The actual index of the newly-inserted element is returned. If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array.
_insert(value: T, onInsert?: (value: T) => any): number
@returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value.
Parameter | Type | Description |
---|---|---|
value | T | The value to insert |
onInsert | (value: T) => any | The optional callback method to call if insertion occurs with the inserted value |
Returns - number
the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value.
Defined in
- core/bentley/src/SortedArray.ts Line 239
Last Updated: 17 December, 2024
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.