< Previous | Contents | Next >

Using Algorithms

The STL defines a group of algorithms that allow you to manipulate elements in containers through iterators. Algorithms exist for common tasks such as searching, randomizing, and sorting. These algorithms are your built-in arsenal of flexible and efficient weapons. By using them, you can leave the mundane task of manipulating container elements in common ways to the STL so you can concentrate on writing your game. The powerful thing about these algorithms is that they are genericthe same algorithm can work with elements of different container types.

 

Introducing the High Scores ProgramPreparing to Use AlgorithmsUsing the find() AlgorithmUsing the random_shuffle() AlgorithmUsing the sort() Algorithm