stl - The Standard Template Library (STL) • provides –...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
The Standard Template Library (STL) provides containers: to manage collections of objects iterators: represent a position in a collection * use operator++() to go to the next position * use operator*() to access the element at the posi- tion algorithms: to process the elements in a collection; e.g searching, sorting function objects: to customize algorithms separates data from operation containers to manage data algorithms to provide operations on data iterators to act as the glue between the two all components are templates an example of generic programming 2 types of containers sequence containers: ordered collections; vector , deque list associative containers: sorted collections (ordered by a sorting criterion); set , multiset , map multimap aw/07 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
STL containers provide value semantics they create internal copies of their elements hence they contain the values of the objects inserted rather than the objects themselves basic requirements for container elements must be copyable (by a copy ctor); the copy must be equivalent to the original must be assignable (by the assignment operator) must be destructible (by the dtor) the STL was designed for performance; it performs al- most no error checking any use that violates preconditions results in undefined behaviour as example, user needs to make sure that indexes, aw/07 2
Background image of page 2
Vectors provide random access to a sequence of varying length like dynamic arrays
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

stl - The Standard Template Library (STL) • provides –...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online