ItemID: Integer;
The ItemID property returns index of the element, on which the iterator cursor is currently put.
Sub Main;
Var
M: Matrix[1];
Mm: IMatrix;
Iter: IMatrixIterator;
i: Integer;
Begin
For i := 0 To 10 Do
M[i] := i * 2;
End For;
Mm := M As IMatrix;
Iter := Mm.CreateIterator;
Iter.Move(IteratorDirection.First);
While Iter.Valid Do
If (Iter.ItemID Mod 2) = 0 Then
Debug.WriteLine("Value " + Iter.ItemID.ToString + ": " + Iter.Value);
End If;
Iter.Move(IteratorDirection.Next);
End While;
End Sub Main;
After executing the example a matrix is created and populated with values. This matrix is used to get an iterator, and elements values with even index in a matrix are output in a cycle.
See also: