peekEach

fun peekEach(reverse: Boolean = false, fn: (value: Int) -> Unit)

Calls the given function with each item in this deque.

Example 1

val deque = dequeOf(1, 2, 3)

// Prints:
// 1
// 2
// 3
deque.peekEach { println(it) }

require(deque.size == 3)

Example 2

val deque = dequeOf(1, 2, 3)

// Prints:
// 3
// 2
// 1
deque.peekEach(true) { println(it) }

require(deque.size == 3)

Parameters

reverse

Whether the iteration should happen in reverse from the back of the deque or forwards from the front of the deque.

fn

Function to call with each item in this deque.