Partilhar via


MapIterator.ToString Method

Definition

Retrieves a textual representation of the iterator.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

Returns

The string that describes the iterator.

Remarks

If the iterator points to the first element in the set, the string will contain an indication of this, in the form: "(begin)[ value]". If the iterator does not point to an element (that is, if the MapIterator.more method returns false), the string that is returned is "(end)". If the iterator points to a value, the string is "[ value]", where value is a string representation of the element value.

The following example iterates through an integer or class map, and prints information about each map element. It uses the MapIterator.toString method to return a textual representation of the class in 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); 
    // 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; 
}

Applies to