insert

fun insert(index: Int, value: UShort)

Inserts the given value into this deque at the specified index.

Example

val deque = dequeOf(1, 2, 3, 4) // Deque{1, 2, 3, 4}
deque.insert(2, 9) // Deque{1, 2, 9, 3, 4}

Parameters

index

Index at which the value should be inserted.

Must be a positive value between zero and size (inclusive).

value

Value to insert.

Throws

If the given index is less than zero or greater than size.