NotEmptyMap

interface NotEmptyMap<K, out V> : Map<K, V>

Deprecated

Use the kotools.types.NotEmptyMap type instead.

Replace with

import kotools.types.NotEmptyMap
NotEmptyMap

Representation of maps that contain at least one entry.

Parameters

K

The type of map keys.

V

The type of map values.

Types

Link copied to clipboard

Error thrown when creating a NotEmptyMap fails.

Functions

Link copied to clipboard
abstract fun containsKey(key: K): Boolean
Link copied to clipboard
abstract fun containsValue(value: V): Boolean
Link copied to clipboard
abstract operator fun get(key: K): V?
Link copied to clipboard
abstract fun isEmpty(): Boolean

Properties

Link copied to clipboard
abstract val entries: Set<Map.Entry<K, V>>
Link copied to clipboard
abstract val head: Pair<K, V>

First entry of this map.

Link copied to clipboard
abstract val keys: Set<K>
Link copied to clipboard
abstract val size: Int
Link copied to clipboard

Returns the size of this map as a StrictlyPositiveInt.

Link copied to clipboard
abstract val values: Collection<V>

Extensions

Link copied to clipboard

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

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.

Link copied to clipboard
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.

Link copied to clipboard

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

Link copied to clipboard

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