
walkmc.extensions.collections.Lists.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of walk-server Show documentation
Show all versions of walk-server Show documentation
A spigot fork to kotlin structure and news.
@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