EnumMap

class EnumMap<K : Enum<K>, V : Any>(enums: Array<K>, sourceValues: Array<V?>) : MutableMap<K, V>

An EnumMap is a Map implementation for use with enum type keys only. All of the keys in an EnumMap must come from a single enum that is specified, explicitly as the first parameterized type. EnumMaps are represented internally as arrays. Enum maps are maintained in the natural order of their keys (Enum.ordinals).

This map does not support nulls as valid values. A key-value pair where the value is null is indicative that the "key" is not present.

Author

Richard Arriaga

Parameters

K

The type of Enum keys maintained by this EnumMap

V

The type of the values stored in this EnumMap.

enums

The Array of Enums, in Enum.ordinal order of all the Enum values represented in the Enum. It is expected that all enum values will be present.

sourceValues

The Array of values stored in this Enum.

Constructors

Link copied to clipboard
fun <K : Enum<K>> EnumMap(enums: Array<K>)

Construct an EnumMap.

Link copied to clipboard
fun <K : Enum<K>, V : Any> EnumMap(enums: Array<K>, sourceValues: Array<V?>)

Construct an EnumMap.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun clear()

Removes all elements from this EnumMap.

Link copied to clipboard
open fun compute(p0: K, p1: BiFunction<in K, in V?, out V?>): V?
Link copied to clipboard
open fun computeIfAbsent(p0: K, p1: Function<in K, out V>): V
Link copied to clipboard
open fun computeIfPresent(p0: K, p1: BiFunction<in K, in V, out V?>): V?
Link copied to clipboard
open override fun containsKey(key: K): Boolean
Link copied to clipboard
open override fun containsValue(value: V): Boolean
Link copied to clipboard
open fun forEach(p0: BiConsumer<in K, in V>)
Link copied to clipboard
open operator override fun get(key: K): V?
Link copied to clipboard
open fun getOrDefault(key: K, defaultValue: V): V
Link copied to clipboard
fun getOrNull(key: K): V?

Answer the value if present, otherwise null.

Link copied to clipboard
fun getOrPut(key: K, mappingFunction: (K) -> V): V

Answer the value at the provided key. If no value is available (null is at Enum.ordinal in the sourceValues array), evaluate the lambda, place the resulting value in this map at that key, then answer the value.

Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open fun merge(    p0: K,     p1: V,     p2: BiFunction<in V, in V, out V?>): V?
Link copied to clipboard
open override fun put(key: K, value: V): V?
Link copied to clipboard
open override fun putAll(from: Map<out K, V>)
Link copied to clipboard
open fun putIfAbsent(p0: K, p1: V): V?
Link copied to clipboard
open override fun remove(key: K): V?

Removes the specified key and its corresponding value from this EnumMap.

open fun remove(key: K, value: V): Boolean
Link copied to clipboard
open fun replace(p0: K, p1: V): V?
open fun replace(    p0: K,     p1: V,     p2: V): Boolean
Link copied to clipboard
open fun replaceAll(p0: BiFunction<in K, in V, out V>)
Link copied to clipboard
operator fun set(key: K, value: V)

Update the map with a new value.

Properties

Link copied to clipboard
open override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
Link copied to clipboard
open override val keys: MutableSet<K>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val values: MutableCollection<V>

The Array of values stored in this Enum. null values are not allowed as a null value indicates the absence of a value.