Aracılığıyla paylaş


SetIterator.Delete Method

Definition

Removes the element that is pointed to by the iterator of the set.

public:
 virtual void Delete();
public virtual void Delete ();
abstract member Delete : unit -> unit
override this.Delete : unit -> unit
Public Overridable Sub Delete ()

Remarks

The iterator will point to the next element after calling this method.

The following example 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