Class: Hashtable

Hashtable

new Hashtable()

A generic map (key-value) container.

Mostly used for storing lists of objects for GDevelop generated events.

Members

itemsObject.<string, any>

The content of the Hashtable. Prefer using methods rather than accessing this internal object, unless you need to iterate on the values.

Methods

staticHashtable.newFrom(items){Hashtable}

Construct a Hashtable from a JS object.

Name Type Description
items Object.<string, any>

The content of the Hashtable.

Returns:
Type Description
Hashtable The new hashtable.

Clear the Hashtable.

containsKey(key){boolean}

Verify if a key exists in the Hashtable.

Name Type Description
key string

The key to search in the Hashtable.

Returns:
Type Description
boolean true if the key exists.

firstKey(){string}

Get the first key of the Hashtable.

Returns:
Type Description
string The first key of the Hashtable, or undefined if empty.

Get a value corresponding to a key, or undefined if not found.

Name Type Description
key string

The key associated to the value.

Dump all the keys of the Hashtable to an array (which is cleared first).

Name Type Description
result Array.<string>

The Array where the result gets pushed.

put(key, value)

Add a key-value pair to the Hashtable. If a value already exists for this key, it is overwritten.

Name Type Description
key string

The key.

value any

The value to associate to the key.

Remove the value associated to the specified key.

Name Type Description
key string

The key to remove.

values(result)

Dump all the values of the Hashtable to an array (which is cleared first).

Name Type Description
result Array.<any>

The Array where the results get pushed.