MapIterator

MapIterator inherits Iterator

MapIterator is a type that allows the user to iterate over a range of elements in a Map container. Use the GetIterator method to obtain an iterator to the beginning of the map.

Usage:

Map<int, double> map = Map<int, double>();
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 foreach loop is a more convenient method:

Map<int, double> map = Map<int, double>();
foreach (int key : double data in map)
{
   ...
}

foreach (double data in map) // Only data is needed
{
   ...
}

Methods

Note

Return values from methods that return Object should be cast to the correct key and data types.

bool HasPrev()

Returns true if another element exists before the current element.

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 HasPrev() should be queried before using this method.

Object Key()

Returns the key associated with the current element, which should be cast to the key type of the Map before usage.

Object Data()

Returns the data associated with the current element, which should be cast to the data type of the Map before usage.

See Iterator for a list of methods inherited by all iterator types.