m12_STL - 1 The Standard Template Library An introduction 2...

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

View Full Document Right Arrow Icon
1 The Standard Template Library An introduction
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Standard Template Library (STL) Objective: Reuse common code Common constructs: Generic containers and algorithms STL Part of the C++ Standard Library Developed by Alexander Stepanov and Meng Lee at HP Powerful, template-based components: Containers: template data structures Iterators: like pointers, access elements of containers Algorithms: data manipulation, searching, sorting, etc.
Background image of page 2
3 Common STL Containers first-in, first-out (FIFO) queue last-in, first-out (LIFO) stack Other container one-to-many mapping, duplicates allowed, rapid key-based lookup multimap one-to-one mapping, no duplicates, fast key-based lookup map fast lookup, duplicates allowed multiset fast lookup, no duplicates set Associative containers doubly linked list, fast insertion and deletion anywhere list fast insertions and deletions at front or back direct access to any element deque fast insertions and deletions at back direct access to any element vector Sequence containers Description Standard Library container class
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Iterators Iterators are objects that point to elements in a container Iterators have overloaded operators: ++ (and --) that cause it to point to the next (previous) element in the container operator * (dereferencing operator) that returns the element pointed to by the iterator operator== and operator != Most STL containers have their corresponding iterator class containers have functions begin() that returns an iterator to the first element, and end() that returns an iterator to one after the last element
Background image of page 4
5 Types of Iterators Bidirectional can move forward and backwards Random access Like bidirectional, but can also jump to any element
Background image of page 5

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

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

Page1 / 18

m12_STL - 1 The Standard Template Library An introduction 2...

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

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