AssociativeArray

open external class AssociativeArray<T>(source)

A collection of key-value pairs that is stored as a hash for easy lookup but also provides an array for fast iteration.

See also

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
external var length: Int

Gets the number of items in the collection.

Link copied to clipboard
external var values: ReadonlyArray<T>

Gets an unordered array of all values in the collection. This is a live array that will automatically reflect the values in the collection, it should not be modified directly.

Functions

Link copied to clipboard
external fun contains(key: Int): Boolean

external fun contains(key: String): Boolean

Determines if the provided key is in the array.

Link copied to clipboard
external fun get(key: Int): T

external fun get(key: String): T

Retrieves the value associated with the provided key.

Link copied to clipboard
external fun remove(key: Int): Boolean

external fun remove(key: String): Boolean

Removes a key-value pair from the collection.

Link copied to clipboard
external fun removeAll()

Clears the collection.

Link copied to clipboard
external fun set(key: Int, value: T)

external fun set(key: String, value: T)

Associates the provided key with the provided value. If the key already exists, it is overwritten with the new value.