1 / 10

Intro to the C++ STL

Intro to the C++ STL. Timmie Smith September 6, 2001. 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. Function Objects. Iterators. Containers.

rose-stokes
Download Presentation

Intro to the C++ STL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 Function Objects Iterators Containers Containers

  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://blackwidowers.cs.tamu.edu/projects/staplThe STAPL project page. Includes pointers to other STL resources, STAPL documentation, and forums to discuss STL and STAPL problems. • Register with the site so you can participate and get help • 514F and 514G in the Bright building

More Related