Lecture05

Lecture05 - Lecture 5: The Standard Template Library...

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

View Full Document Right Arrow Icon
Lecture 5: The Standard Template Library
Background image of page 1

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

View Full DocumentRight Arrow Icon
Overview of STL Toolbox of data structures and algorithms Template library, so very flexible Made up of Containers: hold other objects e.g. vector, list, set, map Iterators: allow us to access/manipulate containers Algorithms
Background image of page 2
Example Taken from SGI STL documentation http://www.sgi.com/tech/stl/ vector<int> v(3); v[0] = 7; v[1] = v[0] + 3; v[2] = v[0] + v[1]; reverse(v.begin(), v.end());
Background image of page 3

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

View Full DocumentRight Arrow Icon
STL Iterators Like pointers (pointers are iterators, too) begin() and end() are member functions of every container Return iterators to the container vector<int> v(3); vector<int>::iterator itr1 = v.begin(); begin() returns iterator accessing first item end() returns iterator accessing one position PAST last item
Background image of page 4
Operations on iterators itr++ *itr itr1 == itr2 itr1 != itr2 Bidirectional iterator also has --itr Random access iterator supports itr + 5 itr1 – itr2
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 / 14

Lecture05 - Lecture 5: The Standard Template Library...

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