:orphan: .. **************************************************************************** .. CUI .. .. The Advanced Framework for Simulation, Integration, and Modeling (AFSIM) .. .. The use, dissemination or disclosure of data in this file is subject to .. limitation or restriction. See accompanying README and LICENSE for details. .. **************************************************************************** Map --- .. class:: Map inherits Object :cloneable: :constructible: :container: :class:`Map\` 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 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, :ref:`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 :ref:`basic types` or a script class with a defined ordering (e.g. :class:`WsfTrackId`). For example: * Use the integer platform index as the key, rather than :class:`WsfPlatform`, and lookup the platform using :method:`WsfSimulation.FindPlatform`. * Use the track id as the key, rather than :class:`WsfLocalTrack`, and lookup the track from the platform's track manager. Methods ======= .. method:: int Size() Returns the current number of elements in the map. .. method:: bool Empty() Returns true if there are no elements in the map. .. method:: bool Erase(T1 aKey) Erases the element with the specified key. .. method:: bool Exists(T1 aKey) bool Exists(T1 aKey, T2 aData) Returns true if the element with the specified key exists. .. method:: 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)). .. method:: 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')). .. method:: void Clear() Clears the map. .. method:: T1 ElementKeyAtIndex(int aIndex) Returns the key that is stored at the specified index. .. method:: Set KeySet() Returns the full :class:`Set>` of keys for the map. .. method:: MapIterator GetIterator() Return an iterator that points to the beginning of the map. This is used by the script language to support the :ref:`foreach>` command, but may also be used directly.