popFirstOrGet

fun popFirstOrGet(fn: () -> UByte): UByte

Removes and returns the first item in this deque or returns the value returned by fn if this deque is empty.

Example

val deque = dequeOf(1)

assert(deque.popFirstOrGet { 6 } == 1)
assert(deque.popFirstOrGet { 6 } == 6)

Return

Either the value that was previously the first item in this deque, if this deque was non-empty, or the value returned by fn if this deque was empty.

Parameters

fn

Function that will be used to retrieve the value to return when this deque is empty.

This function will not be called if this deque is not empty.