Templates
Function Templates
Class Templates
STL : Standard Template Library
Components
- algorithm: defines a computational procedure.
- container: manages a set of memory locations.
- iterator: provides a means for an algorithm to traverse through a container.
- function object: encapsulates a function in an object for use by other components.
- adaptor: adapts a component to provide a different interface.
Container Classes
- Sequence Containers
-
vector: rapid insertions and deletions at back,
direct access to any element
- deque: rapid insertions and deletions at front or back,
direct access to any element
- list: doubly-linked list, rapid insertion and deletion anywhere
- Associative Containers
- multiset: rapid lookup, duplicates allowed
- set: rapid lookup, no duplicates allowed
- multimap: one-to-many mapping, duplicates allowed, rapid key-based lookup
- map: one-to-one mapping, no duplicates allowed, rapid key-based lookup
- Container Adapters
- stack: last in first out (LIFO)
- queue: first in first out (FIFO)
- priority_queue: highest priority element is always the first element out
Algorithms
Algoritms can be used generically across a variety of containers.
- Mutating sequence algorithms -- algorithms that result in modification of the containers
- Nonmutating sequence algorithms -- algorithms that do not result in modification of the containers
- Numerical algorithms
- Sorting Algoritms
Examples
- fill, fill_n, generate, generate_n
- replace, replace_if, replace_copy, replace_copy_if
- equal, mismatch, lexicographical_compare
- remove, remove_if, remove_copy, remove_copy_if
- Mathematical Algorithms : random_shuffle, count, count_if, min_element, max_element,
accumulate, for_each, transform
- Basic Searching and Sorting Algorithms : find, find_if, sort, binary_search
- copy_backward, merge, unique, reverse
- inplace_merge, unique_copy, reverse_copy
- Set operations : includes, set_union, set_intersection, set_difference, set_symmetric_difference
- lower_bound, upper_bound, equal_range
Function Object
Function Object Example
References
Other Links