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

walkmc.extensions.collections.Lists.kt Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
@file:Suppress("NOTHING_TO_INLINE")

package walkmc.extensions.collections

import java.util.*

/**
 * Creates a new empty mutable list.
 */
inline fun  newMutableList(): MutableList = mutableListOf()

/**
 * Creates a new mutable list with the specified elements.
 */
inline fun  newMutableList(vararg elements: T): MutableList = mutableListOf(*elements)

/**
 * Creates a new empty list.
 */
inline fun  newList(): List = listOf()

/**
 * Creates a new list with the specified elements.
 */
inline fun  newList(vararg elements: T): List = listOf(*elements)

/**
 * Adds all specified [values] to this list.
 */
fun  MutableList.add(vararg values: T) = addAll(values.toList())

/**
 * Rotates this list by the specified [distance]. Negative distance is allowed to represents thats
 * the rotation will be in reverse direction.
 */
fun  MutableList.rotate(distance: Int): MutableList {
	Collections.rotate(this, distance)
	return this
}

/**
 * Creates a new empty linked list.
 */
fun  linkedListOf() = LinkedList()

/**
 * Creates a new linked list with the specified [elements].
 */
fun  linkedListOf(vararg elements: T) = LinkedList(elements.toList())




© 2015 - 2025 Weber Informatics LLC | Privacy Policy