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.

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

/**
 * --------------------------------------------------------
 * Include via: <script src="core.js"></script>
 * Access items like: am4.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

[Symbol.iterator]()

#

Returns Iterator < ... >

Returns an ES6 iterator for the keys/values of the dictionary.

clear()

#

Returns void

Removes all items from the dictionary.

constructor()

#

Returns Dictionary

Constructor

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 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 { key: Key,
  newValue: Value,
  type: "insertKey",
  target: Dictionary }

Invoked when insertKey() method is called.

#removeKey

Param { key: Key,
  oldValue: Value,
  type: "removeKey",
  target: Dictionary }

Invoked when removeKey() method is called.

#removed

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

Invoked when an item is removed from the dictionary.

#setKey

Param { key: Key,
  newValue: Value,
  oldValue: Value,
  type: "setKey",
  target: Dictionary }

Invoked when setKey() method is called.

Adapters

Dictionary does not have any adapters.