O'Reilly logo

Efficient C++ Performance Programming Techniques by David Mayhew, Dov Bulka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Find

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(), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required