Intro to the C++ STL Timmie Smith September 6, 2001.

Slides:



Advertisements
Similar presentations
M The University Of Michigan Andrew M. Morgan EECS Lecture 22 Savitch Ch. 16 Intro To Standard Template Library STL Container Classes STL Iterators.
Advertisements

Copyright © 2002 Pearson Education, Inc. Slide 1.
Chapter 19 Standard Template Library. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Iterators Constant and mutable.
SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
Data Structures Using C++ 2E
. STL: C++ Standard Library (continued). STL Iterators u Iterators are allow to traverse sequences u Methods  operator*  operator->  operator++, and.
C++ Sets and Multisets Set containers automatically sort their elements automatically. Multisets allow duplication of elements whereas sets do not. Usually,
. STL: C++ Standard Library. Main Ideas u General purpose: generic data structures & algorithms, templates u Flexibility: Allows for many combinations.
What is generic programming? The essence of the generic programming approach is concept development: systematic classification of computing components.
COMP 171 Data Structures and Algorithms Tutorial 1 Template and STL.
. The Standard C++ Library. 2 Main Ideas Purpose Flexibility Efficiency Simple & Uniform Interface.
Concept= a set of abstractions (e.g., types) (Generic Programming) Programming with Concepts defined by a set of requirements {vector, deque, list, set,
Quick Overview of STL STL = Standard Template Library Main concept : Container, Iterator Application : Linked list, Stack etc.
C++ Programming: Program Design Including Data Structures, Second Edition Chapter 22: Standard Template Library (STL)
CMSC 202 Lesson 24 Iterators and STL Containers. Warmup Write the class definition for the templated Bag class – A bag has: Random insertion Random removal.
Data Structures Using C++1 Chapter 13 Standard Template Library (STL) II.
1 Iterators & Algorithms Iterators provide a link between containers and algorithms Example: We wish to write a function sum() that adds up the members.
Generic programming starts with algorithms. Lift Minimal requirements: works with maximal family of types Concrete algorithm: requires specific data type.
. STL: C++ Standard Library (continued). STL Iterators u Iterators are allow to traverse sequences u Methods  operator*  operator->  operator++, and.
Standard Template Library C++ introduced both object-oriented ideas, as well as templates to C Templates are ways to write general code around objects.
Lecture 23 Today Standard Template Library Programs in: programs/p19 Bibliography: Textbook p.252,
Spring 2010 Advanced Programming Section 1-STL Computer Engineering Department Faculty of Engineering Cairo University Advanced Programming Spring 2010.
Data Structures Using C++ 2E
Adaptive Parallel Sorting Algorithms in STAPL Olga Tkachyshyn, Gabriel Tanase, Nancy M. Amato
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
PRESENTED BY: RAJKRISHNADEEPAK.VUYYURU SWAMYCHANDAN.DONDAPATI VINESHKUMARREDDY.LANKA RAJSEKHARTIRUMALA KANDURI ALAN.
Generic Programming Using the C++ Standard Template Library.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Standard Template Library (STL)
Data Structures Using C++ 2E Chapter 13 Standard Template Library (STL) II.
C++ STL CSCI 3110.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 22: Standard Template Library (STL)
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
1 Iterators Good reference site:
CS 403, Class 23Slide #1 CS Programming Languages Class 23 November 16, 2000.
 2003 Prentice Hall, Inc. All rights reserved.m ECE 2552 Dr. Këpuska based on Dr. S. Kozaitis Summer Chapter 15 - Class string and String Stream.
Lecture 7 : Intro. to STL (Standard Template Library)
CS 403: Programming Languages Lecture 24 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 STL Containers Copyright Kip Irvine, All rights reserved. Only students enrolled in a class at Florida International University may copy or print.
STL – Standard Template Library L. Grewe. 2 Goals Lots of important algorithms, data structures in CS using Templates. is a software library partially.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Copyright © 2009 – Curt Hill Standard Template Library An Introduction.
Introduction The STL is a complex piece of software engineering that uses some of C++'s most sophisticated features STL provides an incredible amount.
C++ Review STL CONTAINERS.
A recap of the STL and more containers Plus an intro to string and file input and output! Lecture 8.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
Object-Oriented Programming (OOP) Lecture No. 42.
Unit VI.  C++ templates are a powerful mechanism for code reuse, as they enable the programmer to write code (classes as well as functions) that behaves.
1 The Standard Template Library The STL is a collection of Container classes These are class templates for containers. A container is an object that stores.
A Parallel Communication Infrastructure for STAPL
Object-Oriented Programming (OOP) Lecture No. 41
CS212: Object Oriented Analysis and Design
COP 3530 Data Structures & Algorithms
Regarding homework 9 Many low grades
Programming with ANSI C ++
Standard Template Library (STL)
Programming with Concepts
Chapter 22: Standard Template Library (STL)
Miscellaneous Stuff Which there wasn’t enough time to cover
CS212: Object Oriented Analysis and Design
Generic Programming Karl Lieberherr 12/1/2018 Generic Programming.
Containers, Iterators, Algorithms, Thrust
Standard Template Library Model
Standard Template Library
Iterators and STL Containers
Standard Template Library
Standard Template Library
Some Definitions vector, string, deque, and list are standard sequence containers. set, multiset, map, multimap, unordered_set, unordered_multiset, unordered_map.
Standard Template Library
Presentation transcript:

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

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

STL Containers Sequence Containers – Vectors, Linked Lists, and derivatives Container Adaptors – Queue, Priority Queue, Stack Associative Containers – Hash, Map, Set

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],, >=

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

Example Program

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

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

STAPL and STL Resources SGI’s STL reference documentation The 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