Share via


MapIterator Class

The MapIterator class is used to iterate over the elements in a map.

Syntax

class MapIterator extends Object

Run On

Called

Methods

  Method Description
Gg941584.pubmethod(en-us,AX.60).gif begin Moves the iterator to the start of the map.
Gg941584.pubmethod(en-us,AX.60).gif cancelTimeOut Cancels a previous method call to the setTimeOut method. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif definitionString Retrieves a textual representation of the iterator type, for example, the "[int -> str] iterator".
Gg941584.pubmethod(en-us,AX.60).gif delete Removes the element that is pointed to by the iterator from the map.
Gg941584.pubmethod(en-us,AX.60).gif domainValue Returns the value of the key in the (key, value) pair that is referred to by the iterator.
Gg941584.pubmethod(en-us,AX.60).gif end Moves the iterator past the last element in the map.
Gg941584.pubmethod(en-us,AX.60).gif equal Determines whether the specified object is equal to the current one. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif find Searches for the specified key value.
Gg941584.pubmethod(en-us,AX.60).gif getTimeOutTimerHandle Returns the timer handle for the object. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif handle Retrieves the handle of the class of the object. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif key Returns the key from the (key, value) pair that is referred to by the iterator.
Gg941584.pubmethod(en-us,AX.60).gif more Determines whether the iterator finds a valid (key, value) pair.
Gg941584.pubmethod(en-us,AX.60).gif new Creates a new iterator for a map that allows you to traverse through the elements in the map. (Overrides the new Method.)
Gg941584.pubmethod(en-us,AX.60).gif next Moves the iterator to the next (key, value) pair.
Gg941584.pubmethod(en-us,AX.60).gif notify Releases the hold on an object that has called the wait method on this object. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif notifyAll Releases a lock on the object that was issued by the wait method on this object. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif objectOnServer Determines whether the object is on a server. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif owner Returns the instance that owns the object. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif rangeValue Returns the value of the "value" in the (key, value) pair referred to by the iterator.
Gg941584.pubmethod(en-us,AX.60).gif setTimeOut Sets up the scheduled execution of a specified method. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif toString Retrieves a textual representation of the iterator. (Overrides the toString Method.)
Gg941584.pubmethod(en-us,AX.60).gif usageCount Returns the current number of references, that is, the value of the reference counter, that the object has. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif value Returns the value from the (key, value) pair referred to by the iterator.
Gg941584.pubmethod(en-us,AX.60).gif valuePair Retrieves a container that contains the key and the value.
Gg941584.pubmethod(en-us,AX.60).gif wait Pauses a process. (Inherited from Object.)
Gg941584.pubmethod(en-us,AX.60).gif xml Returns an XML string that represents the current object. (Inherited from Object.)

Top

Remarks

Map iterators are used to iterate over the elements in a map. They can be viewed as simple pointers into the maps over which they iterate. Functionality is available to start the iteratation, to determine whether more (key, value) pairs are available, and to fetch the element pointed to by the iterator.

It is better to use than MapIterator. Map iterators and the maps over which they iterate must be on the same Client/Server side. If you use MapIterator, and code is marked as Called from, it is possible that the map and the iterator will end up on different tiers, and the code will fail. If you use MapEnumerator, the enumerator is automatically created on the same tier as the map. Also, to move to the next item in a map you must explicitly call the more and next methods if you are using a map iterator. If you use MapEnumerator, you only have to call moveNext method.

The sequence in which the elements are inserted does not determine the order in which they occur. The order is defined by the ordering of the elements. Elements with lower keys appear before elements with higher keys. The usual ordering for the types is used. However, if the keys are objects, the addresses of the objects are used to supply the ordering and no specific ordering may consequently be inferred. The addresses of the objects are transient by nature.

Examples

The following example creates a map and adds three key, value pairs. It then iterates through the map, printing out information about each map element.

{ 
    Map iim = new Map(Types::Integer, Types::Class); 
    MapIterator it; 
  
    // Add some elements into the map 
    iim.insert(1, new query()); 
    iim.insert(2, new query()); 
    iim.insert(4, new query()); 
  
    // Create a map iterator 
    it = new MapIterator (iim); 
  
    // Print "[int -> class] iterator" 
    print it.definitionString();     
  
    // Go on for as long as elements are found in the map 
    while (it.more()) 
    { 
        // Print each key (1, 2, 4) 
        print it.key();  
  
        // Print text representation of each value 
        print it.value().toString();  
 
        // Fetch next element in map 
        it.next(); 
    } 
    pause; 
}

Inheritance Hierarchy

Object Class
  MapIterator Class

See Also

Map Class

MapEnumerator Class