Lecture06-1-2

Lecture06-1-2 - More on STL Continue STL notes from last...

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

View Full Document Right Arrow Icon
CS2134 More on STL Continue STL notes from last lecture: STL algorithms find does sequential search. Does comparisons using == operator find_if does sequential search for object satisfying a predicate
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS2134 lower_bound does binary search on range [first,last) container must be sorted need random access iterator for runtime O(log n) Code (Figure 7.9, p. 244) for random access iterator (STL code is slightly different) note computation of middle iterator returns iterator to leftmost element in [first,last) containing element >= x (if none exists, returns last)
Background image of page 2
CS2134 More STL function objects #include <functional> provides some useful function objects, e.g. template class <Object> class less { public:       {return lhs < rhs} }
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS2134 Associative Containers Set: collection of objects, indexed by the object’s value Map: collection of pairs valuetype=pair<key_type,data_type> indexed by keytype Efficient (O(log n) worst case) find and insert methods, which take value as parameter Iteration through set or map visits items in order (according to comparision provided by a functor) Related containers: Sets and maps are both unique sorted associative containers ; non-unique versions are multi-set and multi-map; hashmap provides O(1) average case for find and insert, but bad worst case and is not sorted.
Background image of page 4
CS2134 Sets Unique (no duplicates) ordered container Supports insertion, deletion, and find in
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.

This note was uploaded on 12/09/2009 for the course CS 2134 taught by Professor Hellerstein during the Spring '07 term at NYU Poly.

Page1 / 15

Lecture06-1-2 - More on STL Continue STL notes from last...

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