# NonEmptySet

value class NonEmptySet<out A> : Set<A> , NonEmptyCollection<A> (source)

## Constructors

constructor(first: A, rest: Set<A>)

## Properties

open override val size: Int

## Functions

fun <A, B> Iterable<A>.align(b: Iterable<B>): List<Ior<A, B>>

Combines two structures by taking the union of their shapes and using Ior to hold the elements.

inline fun <A, B, C> Iterable<A>.align(b: Iterable<B>, fa: (Ior<A, B>) -> C): List<C>

Combines two structures by taking the union of their shapes and combining the elements with the given function.

operator fun <A : Comparable<A>> Iterable<A>.compareTo(other: Iterable<A>): Int
open operator override fun contains(element: A): Boolean
open override fun containsAll(elements: Collection<A>): Boolean
fun <A, B> Iterable<A>.crosswalk(f: (A) -> Iterable<B>): List<List<B>>
fun <A, K, V> Iterable<A>.crosswalkMap(f: (A) -> Map<K, V>): Map<K, List<V>>
fun <A, B> Iterable<A>.crosswalkNull(f: (A) -> B?): List<B>?
open override fun distinct(): NonEmptyList<A>
open inline override fun <K> distinctBy(selector: (A) -> K): NonEmptyList<A>

Returns an element as Some at the given index or None if the index is out of bounds of this iterable.

open operator override fun equals(other: Any?): Boolean

Returns the first element as Some, or None if the iterable is empty.

inline fun <T> Iterable<T>.firstOrNone(predicate: (T) -> Boolean): Option<T>

Returns the first element as Some matching the given predicate, or None if element was not found.

open fun firstOrNull(): A
open inline override fun <B> flatMap(transform: (A) -> NonEmptyCollection<B>): NonEmptyList<B>

Flatten an Iterable of Either. Alias for mapOrAccumulate over an Iterable of computed Either. Either returns a List containing all Either.Right values, or a NonEmptyList of all Either.Left values.

@JvmName(name = "flattenNelOrAccumulate")
fun <Error, A> Iterable<EitherNel<Error, A>>.flattenOrAccumulate(): Either<NonEmptyList<Error>, List<A>>

Flatten an Iterable of Either. Alias for mapOrAccumulate over an Iterable of computed Either. Either returns a List containing all Either.Right values, or a NonEmptyList of all EitherNel values.

Flatten an Iterable of Either. Alias for mapOrAccumulate over an Iterable of computed Either. Either returns a List containing all Either.Right values, or Either.Left values accumulated using combine.

@JvmName(name = "flattenNelOrAccumulate")
fun <Error, A> Iterable<EitherNel<Error, A>>.flattenOrAccumulate(combine: (Error, Error) -> Error): Either<Error, List<A>>

Flatten an Iterable of Either. Alias for mapOrAccumulate over an Iterable of computed Either. Either returns a List containing all Either.Right values, or EitherNel values accumulated using combine.

open override fun hashCode(): Int
fun <A> Iterable<A>.interleave(other: Iterable<A>): List<A>

Interleaves the elements of this Iterable with those of other. Elements of this and other are taken in turn, and the resulting list is the concatenation of the interleaved elements. If one Iterable is longer than the other, the remaining elements are appended to the end.

open override fun isEmpty(): Boolean
open operator override fun iterator(): Iterator<A>

Returns the last element as Some, or None if the iterable is empty.

inline fun <T> Iterable<T>.lastOrNone(predicate: (T) -> Boolean): Option<T>

Returns the last element as Some matching the given predicate, or None if no such element was found.

open override fun lastOrNull(): A
fun <A, B> Iterable<A>.leftPadZip(other: Iterable<B>): List<Pair<A?, B>>

Returns a List containing the zipped values of the two lists with null for padding on the left.

inline fun <A, B, C> Iterable<A>.leftPadZip(other: Iterable<B>, fab: (A?, B) -> C): List<C>

Returns a List containing the result of applying some transformation (A?, B) -> C on a zip, excluding all cases where the right value is null.

open inline override fun <B> map(transform: (A) -> B): NonEmptyList<B>
open inline override fun <B> mapIndexed(transform: (index: Int, A) -> B): NonEmptyList<B>

Returns Either a List containing the results of applying the given transform function to each element in the original collection, or accumulate all the logical errors into a NonEmptyList that were raised while applying the transform function.

inline fun <Error, A, B> Iterable<A>.mapOrAccumulate(combine: (Error, Error) -> Error, transform: RaiseAccumulate<Error>.(A) -> B): Either<Error, List<B>>

Returns Either a List containing the results of applying the given transform function to each element in the original collection, or accumulate all the logical errors that were raised while transforming the collection using the combine function is used to accumulate all the logical errors.

fun <A, B> Iterable<A>.padZip(other: Iterable<B>): List<Pair<A?, B?>>

Returns a List containing the zipped values of the two lists with null for padding.

inline fun <A, B, C> Iterable<A>.padZip(other: Iterable<B>, fa: (A?, B?) -> C): List<C>

Returns a List containing the result of applying some transformation (A?, B?) -> C on a zip.

inline fun <A, B, C> Iterable<A>.padZip(other: Iterable<B>, left: (A) -> C, right: (B) -> C, both: (A, B) -> C): List<C>
open operator override fun plus(element: A): NonEmptySet<A>
open operator override fun plus(elements: Iterable<A>): NonEmptySet<A>
inline fun <A, B> Iterable<A>.reduceOrNull(initial: (A) -> B, operation: (acc: B, A) -> B): B?
fun <A, B> Iterable<A>.rightPadZip(other: Iterable<B>): List<Pair<A, B?>>

Returns a List> containing the zipped values of the two lists with null for padding on the right.

inline fun <A, B, C> Iterable<A>.rightPadZip(other: Iterable<B>, fa: (A, B?) -> C): List<C>

Returns a List containing the result of applying some transformation (A, B?) -> C on a zip, excluding all cases where the left value is null.

Separate the inner Either values into the Either.Left and Either.Right.

inline fun <T, A, B> Iterable<T>.separateEither(f: (T) -> Either<A, B>): Pair<List<A>, List<B>>

Applies a function f to each element and returns a pair of arrays: the first one made of those values returned by f that were wrapped in Either.Left, and the second one made of those wrapped in Either.Right.

fun <A, B> Iterable<Ior<A, B>>.separateIor(): Pair<List<A>, List<B>>

splits a union into its component parts.

Returns single element as Some, or None if the iterable is empty or has more than one element.

inline fun <T> Iterable<T>.singleOrNone(predicate: (T) -> Boolean): Option<T>

Returns the single element as Some matching the given predicate, or None if element was not found or more than one element was found.

fun <A> Iterable<A>.split(): Pair<List<A>, A>?

Attempt to split the Iterable into the tail and the first element. Returns null if the Iterable is empty, otherwise returns a Pair of the tail and the first element.

fun <A> Iterable<A>.tail(): List<A>

Alias for drop(1)

open override fun toString(): String
fun <A, B> Iterable<A>.unweave(ffa: (A) -> Iterable<B>): List<B>

interleaves the elements produced by applying ffa to every element of this Iterable.

fun <A, B> Iterable<Pair<A, B>>.unzip(): Pair<List<A>, List<B>>

unzips the structure holding the resulting elements in an Pair

inline fun <A, B, C> Iterable<C>.unzip(fc: (C) -> Pair<A, B>): Pair<List<A>, List<B>>

after applying the given function unzip the resulting structure into its elements.

fun <B, A : B> Iterable<A>.widen(): Iterable<B>

Given A is a subtype of B, re-type this value from Iterable to Iterable