10. Algorithms

Do not multiply entities beyond necessity.

– William Occam

Introduction

Use of Iterators

Iterator Types

Stream Iterators

Predicates

Algorithm Overview

Container Algorithms

Advice

10.1. Introduction

A data structure, such as a list or a vector, is not very useful on its own. To use one, we need operations for basic access such as adding and removing elements (as is provided for list and vector). Furthermore, we rarely just store objects in a container. We sort them, print them, extract subsets, remove elements, search for objects, etc. Consequently, the standard library provides the most common algorithms for containers in addition to providing the most common container types. For example, the we can simply and ...

Get A Tour of C++ 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.