Script unit that provides methods to create and manipulate dictionaries. A dictionary is a map with string keys and values of a specified type.
Methods |
---|
Removes all of the mappings from the dictionary. |
function clone(dict: dict): dict Returns a shallow clone of the dictionary. |
function containsKey(dict: dict, key: string): boolean Returns true if the dictionary contains a mapping for the specified key. |
function containsValue(dict: dict, value: T): boolean Returns true if the dictionary maps one or more keys to the specified value. |
function equals(dict1: dict, dict2: dict): boolean Compares two dictionaries for equality. |
function get(dict: dict, key: string): T Returns the value to which the specified key is mapped, or null if the dictionary contains no mapping for the key. |
function getOrDefault(dict: dict, key: string, defaultValue: T): T Returns the value to which the specified key is mapped, or the default value if the dictionary contains no mapping for the key. |
function isEmpty(dict: dict): boolean Returns true if the dictionary is null or empty. |
function keys(dict: dict): set Returns a set view of the keys contained in the dictionary. |
function of(key1: string, value1: T [, key2: string, value2: T]...): dict Creates a dictionary with the specified key-value pairs. |
procedure put(dict: dict, key: string, value: T) Associates the specified value with the specified key in the dictionary. |
procedure putAll(dest: dict, src: dict) Copies all of the mappings from the source dictionary to the destination dictionary. |
function remove(dict: dict, key: string): T Removes the mapping for a key from the dictionary if it is present. |
function size(dict: dict): integer Returns the number of key-value mappings in the dictionary. |
function values(dict: dict): collection Returns a collection view of the values contained in the dictionary. |
procedure clear(dict: dict)
Removes all of the mappings from the dictionary.
Parameters :
dict: the dictionary to be cleared.
Can be used in:
function clone(dict: dict): dict
Returns a shallow clone of the dictionary.
Parameters :
dict: the dictionary to clone.
Return :
a new dictionary with the same entries as the input dictionary.
Can be used in:
function containsKey(dict: dict, key: string): boolean
Returns true if the dictionary contains a mapping for the specified key.
Parameters :
dict: the dictionary.
key: the key whose presence in the dictionary is to be tested.
Return :
true if the dictionary contains a mapping for the specified key, false otherwise. Returns null if the dictionary is null.
Can be used in:
function containsValue(dict: dict, value: T): boolean
Returns true if the dictionary maps one or more keys to the specified value.
Parameters :
dict: the dictionary.
value: the value whose presence in the dictionary is to be tested.
Return :
true if the dictionary maps one or more keys to the specified value, false otherwise. Returns null if the dictionary is null.
Can be used in:
function equals(dict1: dict, dict2: dict): boolean
Compares two dictionaries for equality.
Parameters :
dict1: the first dictionary.
dict2: the second dictionary.
Return :
true if both dictionaries have the same keys and values, false otherwise.
Can be used in:
function get(dict: dict, key: string): T
Returns the value to which the specified key is mapped, or null if the dictionary contains no mapping for the key.
Parameters :
dict: the dictionary.
key: the key whose associated value is to be returned.
Return :
the value to which the specified key is mapped, or null if the dictionary contains no mapping for the key. Returns null if the dictionary is null.
Can be used in:
function getOrDefault(dict: dict, key: string, defaultValue: T): T
Returns the value to which the specified key is mapped, or the default value if the dictionary contains no mapping for the key.
Parameters :
dict: the dictionary.
key: the key whose associated value is to be returned.
defaultValue: the default value to return if the key is not found.
Return :
the value to which the specified key is mapped, or the default value if the dictionary contains no mapping for the key. Returns the default value if the dictionary is null.
Can be used in:
function isEmpty(dict: dict): boolean
Returns true if the dictionary is null or empty.
Parameters :
dict: the input dictionary.
Return :
true if the dictionary is null or empty, false otherwise.
Can be used in:
function keys(dict: dict): set
Returns a set view of the keys contained in the dictionary.
Parameters :
dict: the dictionary.
Return :
a set view of the keys contained in the dictionary. Returns an empty set if the dictionary is null.
Can be used in:
function of(key1: string, value1: T [, key2: string, value2: T]...): dict
Creates a dictionary with the specified key-value pairs.
Parameters :
keysAndValues: an alternating sequence of keys (strings) and values (of type T).
Return :
a new dictionary containing the specified key-value pairs.
Can be used in:
procedure put(dict: dict, key: string, value: T)
Associates the specified value with the specified key in the dictionary.
Parameters :
dict: the dictionary.
key: the key with which the specified value is to be associated.
value: the value to be associated with the specified key.
Can be used in:
procedure putAll(dest: dict, src: dict)
Copies all of the mappings from the source dictionary to the destination dictionary.
Parameters :
dest: the destination dictionary.
src: the source dictionary.
Can be used in:
function remove(dict: dict, key: string): T
Removes the mapping for a key from the dictionary if it is present.
Parameters :
dict: the dictionary.
key: the key whose mapping is to be removed from the dictionary.
Return :
the previous value associated with the key, or null if there was no mapping for the key.
Can be used in:
function size(dict: dict): integer
Returns the number of key-value mappings in the dictionary.
Parameters :
dict: the input dictionary.
Return :
the number of key-value mappings in the dictionary, or 0 if the dictionary is null.
Can be used in:
function values(dict: dict): collection
Returns a collection view of the values contained in the dictionary.
Parameters :
dict: the dictionary.
Return :
a collection view of the values contained in the dictionary. Returns an empty collection if the dictionary is null.
Can be used in: