www.gibmonks.com

Main Page

[Page 1110]

## Chapter 23. Standard Template Library (STL)

The shapes a bright container can contain!

Theodore Roethke

Journey over all the universe in a map.

Miguel de Cervantes

O! thou hast damnable iteration, and art indeed able to corrupt a saint.

William Shakespeare

That great dust heap called "history."

Augustine Birrell

The historian is a prophet in reverse.

Friedrich von Schlegel

Attempt the end, and never stand to doubt; Nothing's so hard but search will find it out.

Robert Herrick

OBJECTIVES

In this chapter you will learn:

• To be able to use the template STL containers, container adapters and "near containers."

• To be able to program with the dozens of STL algorithms.

• To understand how algorithms use iterators to access the elements of STL containers.

• To become familiar with the STL resources available on the Internet and the World Wide Web.

[Page 1111]

Outline

23.1 Introduction to the Standard Template Library (STL)

23.1.1 Introduction to Containers

23.1.2 Introduction to Iterators

23.1.3 Introduction to Algorithms

23.2 Sequence Containers

23.2.1 vector Sequence Container

23.2.2 list Sequence Container

23.2.3 deque Sequence Container

23.3 Associative Containers

23.3.1 multiset Associative Container

23.3.2 set Associative Container

23.3.3 multimap Associative Container

23.3.4 map Associative Container

23.5 Algorithms

23.5.1 fill, fill_n, generate and generate_n

23.5.2 equal, mismatch and lexicographical_compare

23.5.3 remove, remove_if, remove_copy and remove_copy_if

23.5.4 replace, replace_if, replace_copy and replace_copy_if

23.5.5 Mathematical Algorithms

23.5.6 Basic Searching and Sorting Algorithms

23.5.7 swap, iter_swap and swap_ranges

23.5.8 copy_backward, merge, unique and reverse

23.5.9 inplace_merge, unique_copy and reverse_copy

23.5.10 Set Operations

23.5.11 lower_bound, upper_bound and equal_range

23.5.12 Heapsort

23.5.13 min and max

23.5.14 STL Algorithms Not Covered in This Chapter

23.6 Class bitset

23.7 Function Objects

23.8 Wrap-Up

23.9 STL Internet and Web Resources

Summary

Terminology

Self-Review Exercises

Exercises