15.4 Introduction to Algorithms

The Standard Library provides scores of algorithms you’ll use frequently to manipulate a variety of containers. Inserting, deleting, searching, sorting and others are appropriate for some or all of the sequence and associative containers. The algorithms operate on container elements only indirectly through iterators. Many algorithms operate on sequences of elements defined by iterators pointing to the first element of the sequence and to one element past the last element. It’s also possible to create your own new algorithms that operate in a similar fashion so they can be used with the Standard Library containers and iterators. In this chapter, we’ll use the copy algorithm in many examples to copy a container’s ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.