Lecture Notes for SE 598, Data Structures and Algorithms
31 May 2000, Standard Template Library Introduction
- generic programming
- data structures and algorithms - who is to be the boss
- data structures - object-oriented programming
- algorithms - procedural programming
- neither - generic programming
- stl components
- containers - data structures
- generic algorithms - algorithms
- iterators - the link between containers and generic algorithms
- function objects - make generic algorithms useful
- adaptors - make one container into another
- allocators - mystery
- containers - sequence sorted associative
- sequence
- arrays - ordinary c++ arrays
- vector - an array that can grow on one end
- dequeue - an array that can grow and shrink at both ends
- list - dequeue that can grow and shrink at both ends
- sorted associative containers
- sets - a collection of unique objects
- multisets - a collection of objects (bags)
- map - an associative array linking keys to elements
- multimap - associate a key with a set of elements
- generic algorithms
-
find(start, end, item)
- look for item
in the container
part delimited by start
and end
.
-
merge(start1, end1, start2, end2, result)
- merge the contents
of the
container part delimited by start1
and end1
with the
contents of the container part delimited by start2
and end2
and store the result in the container starting at result
.
-
accumulate(start, end, init, op)
- perform op
on the
contents of the container part delimited by start
and end
and
using init
as the initial value; return the result
- lots more
- iterators
- better called accessors
- how do algorithms get at the contents of a container - via the
iterators provided by each container
This page last modified on 31 May 2000.