Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Examples

Example 1: partition. Use partition to just divide the range into two groups: all elements that satisfy the predicate, followed by all elements that don’t. This is all you need to answer questions like these:

  • “Who are all the students with a grade of B+ or better?” For example, partition( students.begin(), students.end(), GradeAtLeast("B+") ); does the work and returns an iterator to the first student whose grade is not at least B+.

  • “What are all the products with weight less than 10kg?” For example, partition( products.begin(), products.end(), WeightUnder(10) ); does the work and returns an iterator to the first product whose weight is 10kg or more.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial