NotEmptySet

@Serializable(with = NotEmptySetSerializer::class)
interface NotEmptySet<out E> : NotEmptyCollection<E> , Set<E>

Deprecated

Use the kotools.types.NotEmptySet type instead.

Replace with

import kotools.types.NotEmptySet
NotEmptySet

Representation of sets that contain at least one element.

Parameters

E

The type of elements contained in this set.

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
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.

open infix operator override fun get(index: Int): 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 isEmpty(): Boolean
Link copied to clipboard
abstract operator override fun iterator(): Iterator<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.