insert Method
Attempt to insert a new value into the map. If an equivalent element already exists in the map, the corresponding index is returned. If the map is full, nothing is inserted and -1 is returned. Otherwise: The new element is mapped to the next-available index (that is, the length of the map prior to insertion of this new element); the value is cloned using the function supplied to the IndexMap constructor; the cloned result is inserted into the map; and the index of the new element is returned.
insert(value: T, onInsert?: (value: T) => any): number
@returns the index of the equivalent element in the map, or -1 if the map is full and no equivalent element exists.
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 of the equivalent element in the map, or -1 if the map is full and no equivalent element exists.
Defined in
- core/bentley/src/IndexMap.ts Line 73
Last Updated: 28 October, 2024