UIntDeque

open class UIntDeque(initialCapacity: Int = 16, val scaleFactor: Float = 1.5f, val maxSize: Int)

Signed UInt Deque

Deque of UInt values.

Author

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

Since

v0.7.0

Parameters

initialCapacity

Initial capacity of the internal data container backing the created deque.

Up to this many values may be added to the deque before the internal data container needs to be resized and reallocated.

scaleFactor

Internal storage reallocation scale factor.

If/when this Deque determines it needs to resize its internal data container to hold additional values being pushed, the internal data container will be resized at a rate of capacity * scaleFactor.

If the scale factor returns a value that is equal to or less than the current capacity, the resize will fall back to a size of capacity + 1.

Default: 1.5

maxSize

Maximum size this deque can grow to.

If adding a value to this Deque would push the size or capacity of the deque to be greater than maxSize then an exception will be thrown.

Default: 2,147,483,647 (Int.MAX_VALUE)

Constructors

Link copied to clipboard
fun UIntDeque(initialCapacity: Int = 16, scaleFactor: Float = 1.5f, maxSize: Int)

Constructs a new Deque instance.

Types

Link copied to clipboard
inner class Iterator
Link copied to clipboard
inner class ReverseIterator

Functions

Link copied to clipboard
inline fun append(value: UInt)

Pushes the given value onto the back of this deque.

Link copied to clipboard
inline fun atCapacity(): Boolean

Tests whether this deque is currently at capacity, or in other words is the number of items in this deque equal to the size of the underlying data container.

Link copied to clipboard
fun clear()

Clears all elements from this dequeue, leaving it empty, but with the same allocated capacity.

Link copied to clipboard
operator fun contains(value: UInt): Boolean

Tests whether this deque contains at least one instance of the given value.

Link copied to clipboard
Link copied to clipboard

Returns the contents of this deque as an array.

Link copied to clipboard
fun ensureCapacity(minCapacity: Int)

Ensures that this deque has at least the given capacity allocated.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
operator fun get(index: Int): UInt

Gets the value at the given index from this deque.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun insert(index: Int, value: UInt)

Inserts the given value into this deque at the specified index.

Link copied to clipboard
inline fun isEmpty(): Boolean

Returns true if this deque contains zero items.

Link copied to clipboard
inline fun isNotEmpty(): Boolean

Returns true if this deque contains one or more items.

Link copied to clipboard

Returns an iterator over the elements in this deque.

Link copied to clipboard
fun peekEach(reverse: Boolean = false, fn: (value: UInt) -> Unit)

Calls the given function with each item in this deque.

Link copied to clipboard
fun peekEachIndexed(reverse: Boolean, fn: (index: Int, value: UInt) -> Unit)

Calls the given function with each item in this deque and its index.

Link copied to clipboard

Returns the first item in this deque.

Link copied to clipboard
fun peekFirstOr(value: UInt): UInt

Returns the first item in this deque if it is not empty, otherwise returns the given value.

Link copied to clipboard
fun peekFirstOrGet(fn: () -> UInt): UInt

Returns the first item in this deque if it is not empty, otherwise returns the value returned by the given function.

Link copied to clipboard

Returns the first item in this deque if it is not empty, otherwise returns null.

Link copied to clipboard

Returns the first item in this deque if it is not empty, otherwise returns the value returned by the given function.

Link copied to clipboard
fun peekLast(): UInt

Returns the last item in this deque.

Link copied to clipboard
fun peekLastOr(value: UInt): UInt

Returns the last item in this deque if it is not empty, otherwise returns the given value.

Link copied to clipboard
fun peekLastOrGet(fn: () -> UInt): UInt

Returns the last item in this deque if it is not empty, otherwise returns the value returned by the given function.

Link copied to clipboard

Returns the last item in this deque if it is not empty, otherwise returns null.

Link copied to clipboard

Returns the last item in this deque if it is not empty, otherwise returns the value returned by the given function.

Link copied to clipboard
inline operator fun plusAssign(value: UInt)
Link copied to clipboard
fun popAt(index: Int): UInt

Removes and returns the element at the given index from this deque.

Link copied to clipboard
fun popEach(reverse: Boolean = false, fn: (value: UInt) -> Unit)

Removes each item off of this deque one at a time and calls the given function with each removed item.

Link copied to clipboard
fun popEachIndexed(reverse: Boolean = false, fn: (index: Int, value: UInt) -> Unit)

Removes each item off of this deque one at a time and calls the given function with each removed item along with the index of that item in the deque.

Link copied to clipboard
fun popFirst(): UInt

Removes the first item from this deque and returns it.

Link copied to clipboard
fun popFirstOr(value: UInt): UInt

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

Link copied to clipboard
fun popFirstOrGet(fn: () -> UInt): UInt

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

Link copied to clipboard

Removes and returns the first item in this deque or returns null if this deque is empty.

Link copied to clipboard

Removes the first item from this deque and returns it.

Link copied to clipboard
fun popLast(): UInt

Removes the last item from this deque and returns it.

Link copied to clipboard
fun popLastOr(value: UInt): UInt

Removes and returns the last item in this deque or returns value if this deque is empty.

Link copied to clipboard
fun popLastOrGet(fn: () -> UInt): UInt

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

Link copied to clipboard

Removes and returns the last item in this deque or returns null if this deque is empty.

Link copied to clipboard
fun popLastOrThrow(fn: () -> Throwable): UInt

Removes the last item from this deque and returns it.

Link copied to clipboard
inline fun prepend(value: UInt)

Pushes the given value onto the front of this deque.

Link copied to clipboard
fun pushFirst(value: UInt)

Pushes the given value onto the front of this deque.

Link copied to clipboard
fun pushLast(value: UInt)

Pushes the given value onto the back of this deque.

Link copied to clipboard

Returns an iterator over the elements in this deque in reverse, starting from the last element and ending with the first.

Link copied to clipboard
operator fun set(index: Int, value: UInt)

Sets the value at the given index from this deque.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Properties

Link copied to clipboard

Currently allocated capacity.

Link copied to clipboard

The amount of space left in this queue's currently allocated backing data container.

Link copied to clipboard

Index of the last element in this deque.

Link copied to clipboard
Link copied to clipboard
val scaleFactor: Float = 1.5f
Link copied to clipboard
var size: Int = 0

Number of elements in this deque.