November 1999
Intermediate to advanced
336 pages
6h 29m
English
The previous discussions of insertion, deletion, and traversal provided scenarios in which each of the array, vector, and list containers had a chance to outperform the other containers under test. We now move on to yet another important operation that will allow the multiset container to shine. This is the case where we need to look up a specific element in a collection. The following code uses the STL's find() to perform a lookup on the various containers:
void arrayFind (int *a, int *collection, int size) { int const value = collection[size/2]; int *p = find(&a[0],&a[size],value); } void vectorFind (vector<int> *v, int *collection, int size) { int const value = collection[size/2]; vector<int>::iterator it = find(v->begin(), v->end(), ...Read now
Unlock full access