Queue

class Queue<T> : Collection<T> , Iterator<T>

FIFO Queue

Example:

// Create a new queue
val queue = Queue<Int>()

for (i in 1 .. 3)
queue += i

for (i in 1 .. 3)
require(stack.next() == i)

Author

Elizabeth Paige Harper - https://github.com/foxcapades

Since

1.0.0

Parameters

T

Type of items that will be appended to this queue.

Constructors

Link copied to clipboard
fun Queue(initialCapacity: Int = 8, scaleFactor: Float = 1.5f, maxSize: Int = Int.MAX_VALUE)

Constructs a new Queue instance.

Functions

Link copied to clipboard
fun append(value: T)

Appends the given value to the tail end of the queue.

Link copied to clipboard
open operator override fun contains(element: T): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<T>): Boolean
Link copied to clipboard
operator fun get(i: Int): T

Gets the target queue element without removing it from the queue.

Link copied to clipboard
open operator override fun hasNext(): Boolean

Tests whether this queue contains at least one more element.

Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Queue<T>
Link copied to clipboard
open operator override fun next(): T

Removes and returns the value from the head of the queue.

Link copied to clipboard
fun peekNext(): T

Returns the value at the head of the queue without removing it.

Link copied to clipboard
operator fun plusAssign(value: T)

Alias for append.

Properties

Link copied to clipboard

Current capacity of this queue.

Link copied to clipboard

The maximum size this queue may grow to.

Link copied to clipboard
open override var size: Int

Current size of this queue.