com.r3corda.core.utilities / NonEmptySet

# NonEmptySet

`class NonEmptySet<T> : MutableSet<T>`

A set which is constrained to ensure it can never be empty. An initial value must be provided at construction, and attempting to remove the last element will cause an IllegalStateException. The underlying set is exposed for Kryo to access, but should not be accessed directly.

### Types

Iterator | `inner class Iterator<out T, T> : MutableIterator<T>`

### Constructors

<init> | `NonEmptySet(initial: T)` A set which is constrained to ensure it can never be empty. An initial value must be provided at construction, and attempting to remove the last element will cause an IllegalStateException. The underlying set is exposed for Kryo to access, but should not be accessed directly.

### Properties

size | `val size: Int`

### Functions

add | `fun add(element: T): Boolean`
addAll | `fun addAll(elements: Collection<T>): Boolean`
clear | `fun clear(): Nothing`
contains | `fun contains(element: T): Boolean`
containsAll | `fun containsAll(elements: Collection<T>): Boolean`
equals | `fun equals(other: Any?): Boolean`
hashCode | `fun hashCode(): Int`
isEmpty | `fun isEmpty(): Boolean`
iterator | `fun iterator(): MutableIterator<T>`
remove | `fun remove(element: T): Boolean`
removeAll | `fun removeAll(elements: Collection<T>): Boolean`
retainAll | `fun retainAll(elements: Collection<T>): Boolean`
toString | `fun toString(): String`

### Extension Functions

noneOrSingle | `fun <T> Iterable<T>.noneOrSingle(predicate: (T) -> Boolean): T?` Returns the single element matching the given predicate, or `null` if element was not found, or throws if more than one element was found. `fun <T> Iterable<T>.noneOrSingle(): T?` Returns single element, or `null` if element was not found, or throws if more than one element was found.