: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. .. **************************************************************************** Iterator -------- .. class:: Iterator An Iterator is a special type of object that provides the means to iterate over 'container' objects, containing a collection of elements of the same type. Each container type provides a GetIterator() method that returns an instance of the appropriate iterator type pointing to the beginning of the container. Iterators can be used directly to iterate over a range of elements in the container, but the :ref:`foreach>` loop is simpler when iterating over the entire container. Methods ======= .. method:: bool HasNext() Returns true if another element exists after the current element. .. method:: Object Next() Increments the iterator to the next element and returns its associated data, which should be cast to the data type of the container before usage. If at the end of the container and no next element exists, invalid data is returned, so :method:`HasNext()` should be queried before using this method. See specialized iterator classes for a list of additional methods available for iterating over specific container types: * :class:`ArrayIterator` * :class:`MapIterator` * :class:`SetIterator`