O'Reilly logo

C++11 for Programmers, Second Edition by Harvey M. Deitel, Abbey Deitel, Paul J. Deitel

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

16.3.6. Basic Searching and Sorting Algorithms

Figure 16.6 demonstrates some basic searching and sorting Standard Library algorithms, including find, find_if, sort, binary_search, all_of, any_of, none_of and find_if_not.

 1   // Fig. 16.6: fig16_06.cpp 2   // Standard Library search and sort algorithms. 3   #include <iostream> 4   #include <algorithm> // algorithm definitions 5   #include <array> // array class-template definition 6   #include <iterator> 7   using namespace std; 8  9   bool greater10( int value ); // predicate function prototype10 11   int main()12   {13      const size_t SIZE = 10;14      array< int, SIZE > a = { 10, 2, 17, 5, 16, 8, 13, 11, 20, 7 };15      ostream_iterator< int > output( cout, ...

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