NotEmptyList

@Serializable(with = NotEmptyListSerializer::class)
interface NotEmptyList<out E> : NotEmptyCollection<E> , List<E>

Deprecated

Use the kotools.types.NotEmptyList type instead.

Replace with

import kotools.types.NotEmptyList
NotEmptyList

Representation of lists that contain at least one element.

Parameters

E

The type of elements contained in this list.

Functions

Link copied to clipboard
abstract operator fun contains(element: E): Boolean
Link copied to clipboard
abstract fun containsAll(elements: Collection<E>): Boolean
Link copied to clipboard
abstract infix operator fun get(index: Int): E
open operator fun get(index: PositiveInt): E

Returns the element at the specified index in this collection, or throws an IndexOutOfBoundsException if the index is out of bounds.

Link copied to clipboard
open infix fun getOrNull(index: Int): E?
open infix fun getOrNull(index: PositiveInt): E?

Returns the element at the specified index in this collection, or returns null if the index is out of bounds.

Link copied to clipboard
abstract fun indexOf(element: E): Int
Link copied to clipboard
abstract fun isEmpty(): Boolean
Link copied to clipboard
abstract operator override fun iterator(): Iterator<E>
Link copied to clipboard
abstract fun lastIndexOf(element: E): Int
Link copied to clipboard
abstract fun listIterator(): ListIterator<E>
abstract fun listIterator(index: Int): ListIterator<E>
Link copied to clipboard
abstract fun subList(fromIndex: Int, toIndex: Int): List<E>
Link copied to clipboard

Returns the string representation of this collection as a NotBlankString.

Properties

Link copied to clipboard
abstract val head: E

First element of this collection.

Link copied to clipboard
abstract val size: Int
Link copied to clipboard

Returns the size of this collection as a StrictlyPositiveInt.

Extensions

Link copied to clipboard
inline fun <E> NotEmptyCollection<E>.getOrElse(index: Int, defaultValue: (Int) -> E): E
inline fun <E> NotEmptyCollection<E>.getOrElse(index: PositiveInt, defaultValue: (PositiveInt) -> E): E

Returns the element at the specified index in this collection, or returns the result of calling the defaultValue function if the index is out of bounds.

Link copied to clipboard

Returns a NotEmptyList containing all the elements of this collection, or throws an IllegalArgumentException if this collection is empty.

Returns a NotEmptyList containing all the elements of this collection, or an IllegalArgumentException if this collection is empty.

Link copied to clipboard
infix inline fun <E> Collection<E>.toNotEmptyListOrElse(defaultValue: (Collection<E>) -> NotEmptyList<E>): NotEmptyList<E>

Returns a NotEmptyList containing all the elements of this collection, or returns the result of calling the defaultValue function if this collection is empty.

Link copied to clipboard

Returns a NotEmptyList containing all the elements of this collection, or returns null if this collection is empty.

Link copied to clipboard

Returns a NotEmptyList containing all the elements of this collection, or throws an IllegalArgumentException if this collection is empty.

Link copied to clipboard

Returns a NotEmptySet containing all the elements of this collection, or an IllegalArgumentException if this collection is empty.

Returns a NotEmptySet containing all the elements of this collection, or throws an IllegalArgumentException if this collection is empty.

Link copied to clipboard
infix inline fun <E> Collection<E>.toNotEmptySetOrElse(defaultValue: (Collection<E>) -> NotEmptySet<E>): NotEmptySet<E>

Returns a NotEmptySet containing all the elements of this collection, or returns the result of calling the defaultValue function if this collection is empty.

Link copied to clipboard

Returns a NotEmptySet containing all the elements of this collection, or returns null if this collection is empty.

Link copied to clipboard

Returns a NotEmptySet containing all the elements of this collection, or throws an IllegalArgumentException if this collection is empty.