Combining_STL_features - Combining STL Features STL has...

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

View Full Document Right Arrow Icon
CSE 332: Combining STL features Combining STL Features STL has containers, iterators, algorithms, and functors With several to many different varieties of each Today we’ll look at some combinations of features With each other and with other parts of C++ and its libraries The goal here is to illustrate and give examples There’s no way we’ll cover everything you could do But hopefully we’ll show that much more can be done Combining STL features generically can be efficient Write less code (and more importantly debug less code) Build more sophisticated programs more easily
Background image of page 1

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

View Full DocumentRight Arrow Icon
CSE 332: Combining STL features Think about the Kinds of Abstractions You Want #include <algorithm> #include <vector> #include <functional> #include <iterator> #include <iostream> #include <cmath> using namespace std; Include libraries you need, e.g., Algorithms Vector container Functors Iterators Input/output streams C math functions Don’t forget to open namespace
Background image of page 2
CSE 332: Combining STL features Let’s Say We Want to Square Some Numbers template <typename T> struct square_functor : public unary_function<T, T> { T operator () (int T) { return T * T; } }; We could use C pow() function
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.

This note was uploaded on 03/03/2010 for the course CSE 241 taught by Professor Cse241 during the Spring '08 term at Washington University in St. Louis.

Page1 / 9

Combining_STL_features - Combining STL Features STL has...

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