Partilhar via


SetIterator.More Method

Definition

Determines whether the iterator denotes a valid set element.

public:
 virtual bool More();
public virtual bool More ();
abstract member More : unit -> bool
override this.More : unit -> bool
Public Overridable Function More () As Boolean

Returns

true if the iterator denotes a valid element; otherwise, false.

Remarks

Attempting to access an element that is pointed to by an iterator when this method returns false will result in an error. This method will check only whether the iterator points to a valid element. It will not check whether there are more elements in the set.

The following example uses the SetIterator.more method to check whether there are more elements in the set before it runs through the while loop, which deletes all the odd elements from the set.

{ 
    Set iset = new Set (Types::Integer); 
    SetIterator it; 
    int i; 
    ; 
    for (i = 1; i <= 10; i++) 
    { 
        iset.add(i); 
    } 
    // Delete all odd elements 
    it = new SetIterator(iset); 
    while (it.more()) 
    { 
        if (it.value() mod 2 != 0) 
        { 
            // The value is odd. Delete and skip to next element. 
            it.delete(); 
        } 
        else 
        { 
            it.next(); 
        } 
    } 
    print iset.toString(); 
    pause; 
}

Applies to