Chapt 16. The Standard Template Library

16.1. STL: (Learn C++)

The collection of classes providing templated containers, iterator and algorithms

16.2. STL Containers: (Learn C++)

A. Sequence Containers: maintain order of elements

1. array: static array

2. vector: dynamic array

3. list: doubly linked list

4. forward_list: singly linked list

5. dequeue: double ended queue

 B. Associative Containers: automatically sort elements when inserted

1. set: unique element

2. multiset: duplicated element allowed

3. map(associative array): key/value pair; key must be unique

4. multimap(dictionary): duplicated key allowed map

C. Container Adapters: special predefined containers for specific use

1. stack: LIFO

2. queue: FIFO

3. priority_queue: maintain highest priority element on the top

16.3. STL Iterators: (Learn C++)

iterator(≈ pointer) is the ‘object’ can traverse a container class

become powerful when combined with STL’s algorithms and functions of containers

std::iterator: read / write

std::const_iterator: read only

16.4. STL Algorithms: (Learn C++)

provide a number of generic algorithms work with container classes by using iterators

can work with all container classes(including custom) providing iterator interface

A. Appetizers

find(): return iterator of the first element in the range

minmax(): return pir<min, max> in the range

sort(): sort all elements ascending order in the range

reverse(): reverse the order of elements in the range

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s