Dictionary

Type class

A Dictionary is collection where values of some type can be mapped to string keys.

You might call it an "associative list" or "associative array".

Sources

Dictionary can be used (imported) via one of the following packages.

// Dictionary is available in all of the following modules.
// You only need to import one of them.

/**
 * --------------------------------------------------------
 * Import from: "core.ts"
 * Use like: am4core.Dictionary
 * --------------------------------------------------------
 */
import * as am4core from "@amcharts/amcharts4/core";

// Dictionary is available in all of the following modules.
// You only need to import one of them.

/**
 * --------------------------------------------------------
 * Include via: <script src="core.js"></script>
 * Access items like: am4core.Dictionary
 * --------------------------------------------------------
 */

Inheritance

Dictionary does not extend any other symbol.

Dictionary is extended by DictionaryTemplate.

Properties

events
#

Type EventDispatcher < AMEvent < Dictionary < Key, T > , IDictionaryEvents < Key, T > > >

Default new EventDispatcher()

Event dispatcher.

Methods

constructor()

#

Returns Dictionary

Constructor

clear()

#

Returns void

Removes all items from the dictionary.

copyFrom(

source: this

)

#

Returns void

Copies items from another Dictionary.

each(

f: ( key: Key, value: T) => void

)

#

Returns void

Calls f for each key/value in the dictionary.

getKey(

key: Key

)

#

Returns Optional < T >

Returns the value for a specific key.

hasKey(

key: Key

)

#

Returns boolean

Returns true if key exists in Dictionary.

insertKey(

key: Key,
value: T

)

#

Returns void

Inserts value at specific key.

Will thrown an exception if the key already exists in the dictionary.

iterator()

#

Returns $iter.Iterator < ... >

Returns an interator that can be used to iterate through all items in the dictionary.

removeKey(

key: Key

)

#

Returns void

Removes value at specific key from dictionary.

setKey(

key: Key,
value: T

)

#

Returns void

Adds or updates key/value into dictionary.

If the key already exists, the old value will be overwritten.

If the new value is exactly the same as the old value (using ===), it won't do anything.

Events

#cleared

Param { type: "cleared",
  target: Dictionary }

Invoked when dictionary is cleared.

#insertKey

Param { type: "insertKey",
  target: Dictionary }

Invoked when insertKey() method is called.

#removeKey

Param { type: "removeKey",
  target: Dictionary }

Invoked when removeKey() method is called.

#removed

Param { type: "removed",
  target: Dictionary }

Invoked when an item is removed from the dictionary.

#setKey

Param { type: "setKey",
  target: Dictionary }

Invoked when setKey() method is called.

Adapters

Dictionary does not have any adapters.