beautypg.com

HP Integrity NonStop J-Series User Manual

Page 129

background image

// set another iterator past the end:
int* theEnd = intCollection + 10;

// iterate through, looking for a 7:
while (iter != theEnd) { // test for end of array
if (*iter == 7) // use '*' to access current element
return true; // found a 7
++iter; // not a 7, try next element
}
return false; // never found a 7

If you compare this code fragment to the one using standard iterators toward the beginning of this
section, you can see the similarities. If you need a bit of help imagining how the standard iterators
work, you can always picture them as generalized pointers.

This manual is related to the following products: