3. Overview Map

A map is a collection that associates a key name with a matrix. The matrix is either a string matrix, a real matrix or a complex matrix. Unlike a Container (see Overview Container) the matrix is not accessed through an index (1,2,3,…) but by a key name like “Engine”, “Test”, etc.

Example

hMap = MapCreate();
MapSetAt(hMap, "Mot-No12", ["1,6l", "4 Valves", "74kW"]);
MapSetAt(hMap, "Mot-No432", ["2.0l", "4 Valves", "100kW"]);
MapSetAt(hMap, "Mot-No42", ["2.5l", "4 Valves", "115kW"]);
MapSetAt(hMap, "Mot-No132", ["3.0l", "4 Valves", "150kW"]);
ssKey = "Mot-No42";
svMotData = MapLookup(hMap, ssKey);
if (ObjGetOk() == FALSE) {
    MessageBox(sprintf("Key \"%s\" not found", ssKey));
    return FALSE;
}
sprintf("The engine has %s" svMotData[3]);

Create and Destroy

MapCreate

MapCreate creates a new map object.

MapDestroy

MapDestroy destroys the given map and frees any memory the map occupied.

Set

MapInitHashTable

MapInitHashTable initializes the hash table.

MapLoad

MapLoad loads a map from a file, that was created with the MapSave function.

MapPrint

MapPrint prints the data elements of a map into the command window.

MapRemoveAt

MapRemoveAt looks up the map entry corresponding to the supplied key. If the key is found, it removes the entry.

MapSave

The MapSave function saves the data elements of a map in a file.

MapSetAt

MapSetAt means to insert an element in a map. First, the key is looked up. If the key is found, then the corresponding value is changed; otherwise a new key-value pair is created.

OBJRemoveMap

OBJRemoveMap

OBJSetMap

OBJSetMap saves a map in an object.

Get

MapCopy

MapCopy creates a copy of the given map object.

MapGetCount

MapGetCount returns the number of elements in the map.

MapGetKeys

MapGetKeys returns a vector of keys.

MapKeyExists

Checks if a key already exists in the map.

MapLookup

MapLookup uses a hashing algorithm to quickly find the map element with a key that exactly matches the given key.

OBJGetMap

OBJGetMap returns a map handle for a given name saved in the specified object.

OBJGetMapNames

OBJGetMapNames returns a string vector with map names or an empty string if the object does not contain any maps.

id-630667