All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.github.lyxnx.util.Collections.kt Maven / Gradle / Ivy

There is a newer version: 1.6.1
Show newest version
package io.github.lyxnx.util

import kotlin.jvm.JvmSynthetic

// ArrayDeque is a kotlin specific collection, so doesn't place nicely with Java

/**
 * Pushes an element into this deque as if it were a stack
 */
@JvmSynthetic
public fun  ArrayDeque.push(element: T) {
    addLast(element)
}

/**
 * Pops an element from this deque as if it were a stack
 *
 * @throws NoSuchElementException if the deque is empty
 */
@JvmSynthetic
public fun  ArrayDeque.pop(): T = removeLast()

/**
 * Pops an element from this deque as if it were a stack or returns null if the deque is empty
 */
@JvmSynthetic
public fun  ArrayDeque.popOrNull(): T? = removeLastOrNull()

/**
 * Creates an [ArrayDeque] with the given [elements]
 */
@JvmSynthetic
public fun  arrayDequeOf(vararg elements: T): ArrayDeque = ArrayDeque(elements.toList())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy