insertAt

fun insertAt(replica: ReplicaId, index: Int, value: V): Pair<Fugue<V>, FugueOp.Insert<V>>

Insert value at visible position index (0 = prepend before first visible element).

Returns the new Fugue state and the FugueOp.Insert op to broadcast.

Runs on the incremental FugueSeqState fast path (#1211): O(1) tree work for an append (amortized — a state rebuild after a remote merge is O(n log n) once), instead of the previous unconditional O(n log n) full tree rebuild per insert. The op minted is bit-identical to the rebuild path's — see insertOpViaRebuildOracle and its differential test.

Throws

if index is outside 0..size.