SetIterator.ToString Method

Definition

Returns a textual representation of the current element in the set that is pointed to by the iterator.

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

Returns

A string that is the textual representation of the current element in the set.

Remarks

If the iterator points to the first element in the set, the string will contain an indication of this, in the following format: "(begin)[value]" If the iterator does not point to an element (that is, if more() returns false), the string 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 uses the SetIterator.toString method to print a description of the value in the set that the iterator points to before it starts traversing the set.

{ 
    Set s1 = new Set (Types::Integer); 
    int theElement; 
    SetIterator it; 
    // Add some elements 
    s1.add(3); 
    s1.add(4); 
    s1.add(13); 
    s1.add(1);  
    // Start a traversal of the elements in the set 
    it = new SetIterator(s1); 
    // The elements are fetched in the order: 1, 3, 4, 13 
    print it.toString(); // Prints "(begin)[1]" 
    while (it.more()) 
    { 
        theElement = it.value(); 
        print theElement; 
        // Fetch the next element 
        it.next(); 
    } 
    pause; 
}

Applies to