: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. .. **************************************************************************** MapIterator ----------- .. class:: MapIterator inherits Iterator MapIterator is a type that allows the user to iterate over a range of elements in a :class:`Map>` container. Use the :method:`GetIterator.GetIterator>` method to obtain an iterator to the beginning of the map. Usage:: Map map = Map(); MapIterator iter = map.GetIterator(); while (iter.HasNext()) { iter.Next(); int key = (int)iter.Key(); double data = (double)iter.Data(); } When iterating over the entire range of the Map, the :ref:`foreach>` loop is a more convenient method:: Map map = Map(); foreach (int key : double data in map) { ... } foreach (double data in map) // Only data is needed { ... } Methods ======= .. note:: Return values from methods that return :class:`Object` should be cast to the correct key and data types. .. method:: bool HasPrev() Returns true if another element exists before the current element. .. method:: Object Prev() Decrements the iterator to the previous element and returns its associated data, which should be cast to the data type of the Map before usage. If at the beginning of the map and no previous element exists, invalid data is returned, so :method:`HasPrev()` should be queried before using this method. .. method:: Object Key() Returns the key associated with the current element, which should be cast to the key type of the Map before usage. .. method:: Object Data() Returns the data associated with the current element, which should be cast to the data type of the Map before usage. See :class:`Iterator` for a list of methods inherited by all iterator types.