Download presentation
Presentation is loading. Please wait.
Published byShannon Griffith Modified over 9 years ago
1
Intro to the C++ STL Timmie Smith September 6, 2001
2
What is the STL? Standard Template Library A collection of classes to make C++ programming more efficient – Algorithms, Containers, and Iterators – Function objects, Allocators, and Adapters Containers Function Objects Iterators
3
STL Algorithms Accept STL Iterators as arguments – Sort(begin, end); 4 categories – Non-modifying For each, Find, Count, Equal, Search, etc. – Mutating Copy, Generate, Reverse, Remove, Swap, etc. – Sorting Related Sort, Stable sort, Binary search, Merge, etc. – Numeric Accumulate, Inner product, Partial sum, Adjacent difference
4
STL Containers Sequence Containers – Vectors, Linked Lists, and derivatives Container Adaptors – Queue, Priority Queue, Stack Associative Containers – Hash, Map, Set
5
STL Iterators Used as arguments to algorithms Containers provide several iterators – Begin, End, Reverse Begin, Reverse End 5 categories – each has specific operations – Input, Output, Forward, Bidirectional, Random Input Operations: =, ==, !=, *, ->, ++, No assignment of *i Output Operations: =, *, ++ Forward Operations: =, ==, !=, *, ->, ++ Bidirectional Operations: =, ==, !=, *, ->, ++, -- Random Operations: =, ==, !=, +=, -=, *, ->, +, ++, -, --, [n],, >=
6
Function Objects Used by some algorithms – Applied to each element in input by For each – Used to create new elements by Generate Predicates - Function Objects that return bool – Unary and Binary predicates used to test equality – Find If uses unary, Sort uses binary
7
Example Program
8
STL Summary STL allows programmers to focus on application specific issues – Provides collections of algorithms, containers, iterators, and other objects – Programmers don’t reinvent the wheel STL has been parallelized by the Standard Template Adaptive Parallel Library (STAPL) project
9
STAPL Overview STAPL provides parallel equivalents of the STL components – pAlgorithms are parallel STL algorithms – pContainers are parallel STL containers – pRanges are parallel extensions of STL iterators STAPL is a superset of the STL – STL is used by STAPL – STAPL and STL can be used in the same program
10
STAPL and STL Resources http://www.sgi.com/tech/stl/ SGI’s STL reference documentation http://www.sgi.com/tech/stl/ http://blackwidowers.cs.tamu.edu/projects/stapl The STAPL project page. Includes pointers to other STL resources, STAPL documentation, and forums to discuss STL and STAPL problems. http://blackwidowers.cs.tamu.edu/projects/stapl – Register with the site so you can participate and get help 514F and 514G in the Bright building
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.