This section describes functions that enable use of hash maps.
The following functions for Map described here are:
mapClear
Removes all entries in a map.
void mapClear (map<any,any> myLittleMap );
Parameter | Description |
---|---|
| The map to clear |
Returns | Nothing |
mapContains
Evaluates if a key is present in a map.
boolean mapContains ( map<any,any> myMap , any myKey );
Parameter | Description |
---|---|
| Name of the map to evaluate |
| The requested key |
Returns |
|
mapCreate
Creates a new, empty map.
map<any,any> mapCreate ( any myKeyType , any myValueType );
Parameter | Description |
---|---|
| Defines the data type of the keys in the map |
| Defines the data type of the values, associated with the keys in the map |
Returns | An empty map |
Example - Using mapCreate
An example of a map definition, including assignment of the first key/value pair.
map<string,int> myMap = mapCreate( string, int); mapSet( myMap, "Failed", 22 );
mapCreateSync
Creates a new, empty synchronized map. This function may be useful for global maps in real time workflows, where the same map may be accessed from several threads at the same time.
map<any,any> mapCreateSync ( any myKeyType , any myValueType );
Parameter | Description |
---|---|
| Defines the data type of the keys in the map |
| Defines the data type of the values, associated with the keys in the map |
Returns | An empty map |
Example - Using mapSet
An example of a map definition, including assignment of the first key/value pair.
map<int,string> mySyncMap = mapCreateSync( int, string); mapSet( mySyncMap, 55, "Successful" );
mapGet
Retrieves the value of a specified key in a map.
valueType mapGet ( map<key,value> myMap , keyType key );
Parameter | Description |
---|---|
| The name of the map from which you want to retrieve a value |
| The name of the key holding the value to you want to retrieve |
Returns | Returns the value associated with the key. The data type of the returned value is the same as the defined value type for the map. If there is no matching key |
Note - using mapGet
If the map is map<int,string>
. The return type of "mapGet" will be "string".
mapKeys
Returns a list of all keys present in a map. Note that the order of the elements in the list is not defined.
list<any> mapKeys(map<any,any> myMap );
Parameter | Description |
---|---|
| The map to fetch all keys from |
Returns | An unsorted list of keys according to: [keyA, keyB, keyX...] The data type of the list elements is the same data type as defined for the keys in the map. |
mapRemove
Removes a key and its corresponding value.
any mapRemove ( map<any, any> myMap , any myKey );
Parameter | Description |
---|---|
| The map to remove a key from |
| The name of the key to remove |
Returns | The value corresponding to the removed key |
mapSet
Sets or updates a key's associated value.
void mapSet ( map<any, any> myMap , any myKey , any myKeyValue );
Parameter | Description |
---|---|
| The map to update |
| The name of the key to set/update |
| The corresponding value to set/update |
Returns | Nothing |
mapSize
Returns the number of keys present in a map.
int mapSize( map<any,any> myMap );
Parameter | Description |
---|---|
| The map to examine |
Returns | The size of the map in terms of number of keys |
mapValues
Returns a list of all values present in a map. Note that the order of the elements in the list is not defined.
list<any>mapValues(map<any, any> myMap );
Parameter | Description |
---|---|
| The map to fetch all values from |
Returns | A list of all values (unsorted): [valueA, valueB, valueX...]. The data type of the list elements is the same data type as defined for the values in the map. |
0 Comments