Package kotools.types.collections

Types

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

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

NotEmptyList
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
interface NotEmptyList<out E> : NotEmptyCollection<E> , List<E>

Representation of lists that contain at least one element.

NotEmptyMap
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.1")
interface NotEmptyMap<K, out V> : Map<K, V>

Representation of maps that contain at least one entry.

NotEmptySet
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
interface NotEmptySet<out E> : NotEmptyCollection<E> , Set<E>

Representation of sets that contain at least one element.

Functions

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.

NotEmptyList
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
fun <E> NotEmptyList(head: E, vararg tail: E): NotEmptyList<E>

Creates a NotEmptyList starting with a head and containing all the elements of the optional tail.

notEmptyListOf
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.0")
fun <E> notEmptyListOf(head: E, vararg tail: E): NotEmptyList<E>

Creates a NotEmptyList starting with a head and containing all the elements of the optional tail.

notEmptyMapOf
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.1")
fun <K, V> notEmptyMapOf(head: Pair<K, V>, vararg tail: Pair<K, V>): NotEmptyMap<K, V>

Creates a NotEmptyMap starting with a head and containing all the entries of the optional tail.

NotEmptySet
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
fun <E> NotEmptySet(head: E, vararg tail: E): NotEmptySet<E>

Creates a NotEmptySet starting with a head and containing all the elements of the optional tail.

notEmptySetOf
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.0")
fun <E> notEmptySetOf(head: E, vararg tail: E): NotEmptySet<E>

Creates a NotEmptySet starting with a head and containing all the elements of the optional tail.

toNotEmptyList
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Array<E>.toNotEmptyList(): NotEmptyList<E>

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

@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Collection<E>.toNotEmptyList(): NotEmptyList<E>

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

toNotEmptyListOrElse
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
infix inline fun <E> Array<E>.toNotEmptyListOrElse(defaultValue: (Array<E>) -> NotEmptyList<E>): NotEmptyList<E>

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

@SinceKotools(project = Project.Types, version = "1.3")
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.

toNotEmptyListOrNull
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Array<E>.toNotEmptyListOrNull(): NotEmptyList<E>?

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

@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Collection<E>.toNotEmptyListOrNull(): NotEmptyList<E>?

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

toNotEmptyListOrThrow
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.2", stability = StabilityLevel.Alpha)
fun <E> Array<E>.toNotEmptyListOrThrow(): NotEmptyList<E>

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

@SinceKotools(project = Project.Types, version = "3.2", stability = StabilityLevel.Alpha)
fun <E> Collection<E>.toNotEmptyListOrThrow(): NotEmptyList<E>

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

toNotEmptyMap
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.1")
fun <K, V> Map<K, V>.toNotEmptyMap(): NotEmptyMap<K, V>

Returns a NotEmptyMap containing all the entries of this map, or throws a NotEmptyMap.ConstructionError if this map is empty.

toNotEmptyMapOrElse
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.1")
inline fun <K, V> Map<K, V>.toNotEmptyMapOrElse(defaultValue: (Map<K, V>) -> NotEmptyMap<K, V>): NotEmptyMap<K, V>

Returns a NotEmptyMap containing all the entries of this map, or returns the result of calling the defaultValue function if this map is empty.

toNotEmptyMapOrNull
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.1")
fun <K, V> Map<K, V>.toNotEmptyMapOrNull(): NotEmptyMap<K, V>?

Returns a NotEmptyMap containing all the entries of this map, or returns null if this map is empty.

toNotEmptyMapOrThrow
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.2", stability = StabilityLevel.Alpha)
fun <K, V> Map<K, V>.toNotEmptyMapOrThrow(): NotEmptyMap<K, V>

Returns a NotEmptyMap containing all the entries of this map, or throws an IllegalArgumentException if this map is empty.

toNotEmptySet
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Array<E>.toNotEmptySet(): NotEmptySet<E>

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

@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Collection<E>.toNotEmptySet(): NotEmptySet<E>

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

toNotEmptySetOrElse
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
infix inline fun <E> Array<E>.toNotEmptySetOrElse(defaultValue: (Array<E>) -> NotEmptySet<E>): NotEmptySet<E>

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

@SinceKotools(project = Project.Types, version = "1.3")
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.

toNotEmptySetOrNull
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Array<E>.toNotEmptySetOrNull(): NotEmptySet<E>?

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

@SinceKotools(project = Project.Types, version = "1.3")
fun <E> Collection<E>.toNotEmptySetOrNull(): NotEmptySet<E>?

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

toNotEmptySetOrThrow
Link copied to clipboard
common
@SinceKotools(project = Project.Types, version = "3.2", stability = StabilityLevel.Alpha)
fun <E> Array<E>.toNotEmptySetOrThrow(): NotEmptySet<E>

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

@SinceKotools(project = Project.Types, version = "3.2", stability = StabilityLevel.Alpha)
fun <E> Collection<E>.toNotEmptySetOrThrow(): NotEmptySet<E>

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