NotEmptyCollection

@SinceKotools(project = Project.Types, version = "1.3")
interface NotEmptyCollection<out E> : Collection<E>

Parent of classes representing collections that contain at least one element.

Parameters

E

The type of elements contained in this collection.

Functions

contains
Link copied to clipboard
common
abstract operator fun contains(element: E): Boolean
containsAll
Link copied to clipboard
common
abstract fun containsAll(elements: Collection<E>): Boolean
get
Link copied to clipboard
common
abstract infix operator fun get(index: Int): E
@SinceKotools(project = Project.Types, version = "1.3")
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.

getOrNull
Link copied to clipboard
common
open infix fun getOrNull(index: Int): E?
@SinceKotools(project = Project.Types, version = "1.3")
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.

isEmpty
Link copied to clipboard
common
abstract fun isEmpty(): Boolean
iterator
Link copied to clipboard
common
abstract operator override fun iterator(): Iterator<E>
toNotBlankString
Link copied to clipboard
common
open fun toNotBlankString(): NotBlankString

Returns the string representation of this collection as a NotBlankString.

Properties

head
Link copied to clipboard
common
abstract val head: E

First element of this collection.

size
Link copied to clipboard
common
abstract val size: Int
typedSize
Link copied to clipboard
common
open val typedSize: StrictlyPositiveInt

Returns the size of this collection as a StrictlyPositiveInt.

Inheritors

NotEmptyList
Link copied to clipboard
NotEmptySet
Link copied to clipboard

Extensions

getOrElse
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
inline fun <E> NotEmptyCollection<E>.getOrElse(index: Int, defaultValue: (Int) -> E): E
@SinceKotools(project = Project.Types, version = "1.3")
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.