addAtIndex

fun <T : Task?> addAtIndex(index: Int, @NonNull newTask: T): T

Insert a task at a specific index in the queue. This is useful for adding tasks that should be run at a specific point in the autonomous sequence. Note that this function immediately produces side effects, and subsequent calls will not be able to insert tasks at the same index due to the shifting of tasks.

Return

the added task

Parameters

index

the index to insert the task at, starting from 0

newTask

the task to add to the run queue

<T>

the inherited task type


fun addAtIndex(index: Int, @NonNull runnable: Runnable): RunTask

Insert an implicit RunTask at a specific index in the queue.

Return

the added RunTask

Parameters

index

the index to insert the task at, starting from 0

runnable

the code to add to the run queue to run once


fun addAtIndex(index: Int, @NonNull name: String, @NonNull runnable: Runnable): RunTask

Insert an implicit RunTask at a specific index in the queue.

Return

the added RunTask

Parameters

index

the index to insert the task at, starting from 0

name

the name of the task

runnable

the code to add to the run queue to run once