Map

Map<T1,T2> inherits Object

Construction: Map<T1,T2> newObj = Map<T1,T2>();
Clone: Map<T1,T2> newObj = Map<T1,T2>(other);
Container

Map<T1,T2> is a sorted associative container type, similar to the C++ STL map, that contains key-value pairs with unique keys. The template types T1 and T2 specify the type of the container’s key and value, respectively, (e.g., Map<int, string> is a map of integers to strings).

Tip

The elements of a Map are sorted using the ordering defined on its key type (T1). With a few exceptions, script classes have no defined ordering, and using them as the key type will result in non-determinism when iterating over the elements of the Map. It is recommended in these use cases to limit keys to basic types or a script class with a defined ordering (e.g. WsfTrackId). For example:

Methods

int Size()

Returns the current number of elements in the map.

bool Empty()

Returns true if there are no elements in the map.

bool Erase(T1 aKey)

Erases the element with the specified key.

bool Exists(T1 aKey)
bool Exists(T1 aKey, T2 aData)

Returns true if the element with the specified key exists.

T2 Get(T1 aKey)

Returns the element with the specified key (aKey). If no element has the specified key, a zero or null value will be returned. You can use the bracket operator ‘[ ]’ instead of Get (e.g., myMap[2] instead of myMap.Get(2)).

void Set(T1 aKey, T2 aData)

Sets the element at the given key (aKey) to the given value (aData). You can use the bracket operator ‘[ ]’ instead of Set (e.g., myMap[2] = ‘hello’ instead of myMap.Set(2, ‘hello’)).

void Clear()

Clears the map.

T1 ElementKeyAtIndex(int aIndex)

Returns the key that is stored at the specified index.

Set<T1> KeySet()

Returns the full Set of keys for the map.

MapIterator GetIterator()

Return an iterator that points to the beginning of the map. This is used by the script language to support the foreach command, but may also be used directly.