Deluge Data Types - Map

Overview

Map is a collection of key value pairs, where each unique key maps to a value. Keys and values can be of any data type say number, text, date, boolean etc. For example, the following table represents a map of books and their authors. Values will be added and retrieved based on the key.

Books (Key)

Origin of species

War and peace

Wealth of Nations

Principia

Authors (Value)

charles Darwin

Leo Tolstoy

Adam Smith

Issac Newton

key - string type

value - can be any type but will be returned as a string

If a value is added with an already existing key, it will overwrite the existing value. In the following example, productDetail is the map variable that holds the value of 'Quantity In Stock' as 10.

As with lists, you can populate map key-value pairs when the map is declared by using curly brace ({}) syntax. Within the curly braces, specify the key first, then specify the value for that key using ":". For example,

My_Map = { "1" : "one", "2" : "two", "3" : "three", "4" : "four" };

In the above example, the value for the key "1" is one, and the value for the key "2" is two. To access the elements in a map, use the Map Methods (link) supported by Deluge.

Map -Built in functions

Functions that operate on Map expression are classified as Map functions. They include functions for returning the number which represent the size of the map, returning the list of keys containing in the map etc. Refer the topic Built-in-functions - Map for the complete list of Map functions.