Introduction The STL is a complex piece of software engineering that uses some of C++'s most sophisticated features STL provides an incredible amount.

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.
Hold data and provide access to it. Random-access containers: -Allow accessing any element by index -arrays, vectors Sequential containers: -Allow accessing.
Chapter 6 Queues and Deques.
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.
Multimaps. Resources -- web For each new class, browse its methods These sites are richly linked, and contain indexes, examples, documents and other resources.
C++ Templates. What is a template? Templates are type-generic versions of functions and/or classes Template functions and template classes can be used.
M180: Data Structures & Algorithms in Java
Beginning C++ Through Game Programming, Second Edition
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.
. 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,
C++ Programming: Program Design Including Data Structures, Second Edition Chapter 22: Standard Template Library (STL)
Data Structures Using C++1 Chapter 13 Standard Template Library (STL) II.
Rossella Lau Lecture 12, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 12: An Introduction to the STL  Basic.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Lecture 23 Today Standard Template Library Programs in: programs/p19 Bibliography: Textbook p.252,
CSIS 123A Lecture 12 Templates. Introduction  C++ templates  Allow very ‘general’ definitions for functions and classes  Type names are ‘parameters’
Spring 2010 Advanced Programming Section 1-STL Computer Engineering Department Faculty of Engineering Cairo University Advanced Programming Spring 2010.
Data Structures Using C++ 2E
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
PRESENTED BY: RAJKRISHNADEEPAK.VUYYURU SWAMYCHANDAN.DONDAPATI VINESHKUMARREDDY.LANKA RAJSEKHARTIRUMALA KANDURI ALAN.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
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)
Templates code reuse - inheritance - template classes template classes - a class that is not data-type specific - eg. a class of Array of any type - intArray,
An Introduction to STL. The C++ Standard Template Libraries  In 1990, Alex Stepanov and Meng Lee of Hewlett Packard Laboratories extended C++ with a.
Data Structures Using C++1 Chapter 4 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.
CS 403, Class 23Slide #1 CS Programming Languages Class 23 November 16, 2000.
CS212: Object Oriented Analysis and Design Lecture 24: Introduction to STL.
Lecture 7 : Intro. to STL (Standard Template Library)
Computer Science and Software Engineering University of Wisconsin - Platteville 11.Standard Template Library Yan Shi CS/SE 2630 Lecture Notes.
CS 403: Programming Languages Lecture 24 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Intro to the C++ STL Timmie Smith September 6, 2001.
Standard Template Library (STL) - Use Vector and Deque
Copyright © 2006 Pearson Addison-Wesley. All rights reserved Today’s Learning Objective  Standard Template Library.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More Linking.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Lecture 7.  There are 2 types of libraries used by standard C++ The C standard library (math.h) and C++ The C++ standard template library  Allows us.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Function Templates 16.2.
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.
Object-Oriented Programming (OOP) Lecture No. 41
Standard Template Library
CS212: Object Oriented Analysis and Design
Programming with ANSI C ++
Standard Template Library
Standard Template Library (STL)
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
Chapter 22: Standard Template Library (STL)
Miscellaneous Stuff Which there wasn’t enough time to cover
Today’s Learning Objective
CS212: Object Oriented Analysis and Design
Generic Programming Karl Lieberherr 12/1/2018 Generic Programming.
Standard Template Library Model
Copyright © – Curt Hill STL List Details Copyright © – Curt Hill.
Standard Template Library
Standard Template Library
Presentation transcript:

Introduction The STL is a complex piece of software engineering that uses some of C++'s most sophisticated features STL provides an incredible amount of generic programming power It provides general purpose, templatized classes and functions The STL is mainly composed of generic container class templates and a set of many efficient template algorithms 2Standard Template Library

Components of STL Container Classes Generic Algorithms Iterators Function Objects Allocators Adaptors 3Standard Template Library

CONTAINERS 4Standard Template Library

Introduction to Containers Container is an object that holds another object More powerful and flexible than arrays It will grow or shrink dynamically and manage their own memory keep track of how many objects they hold 5Standard Template Library

Types of Containers 6Standard Template Library

Syntax Standard Sequence Containers Vectors, Lists, De-queue, and Strings template > Where T is the data type to use and A is the storage allocator which defaults to the standard allocator for type T 7Standard Template Library

Vectors It is the type of sequence container that should be used by default It can change size dynamically It provides best random access performance It permits insertions and deletions at the back Template Specification The template specification for vector is shown here: template > class vector Here T is the type of the data stored, A is the storage allocator 8Standard Template Library

Template Specification Lists The list container implements a doubly linked list It supports a bidirectional, i.e. they may be accessed front to back or back to front Unlike a vector, which supports random access, a list can be accessed sequentially only. It provides insertions and deletions anywhere in the list template > class list Here T is the type of the data stored in the list and Allocator provides default storage location 9Standard Template Library

10Standard Template Library

Introduction An iterator is an extension to the pointer It implements the standard pointer operators It gives you the ability to cycle through the contents of the container like a pointer to cycle through an array Iterators used by the algorithms to move through the containers Syntax std::class_name :: iterator name where name - name of the iterator, class_name - name of the STL container, template_parameters - parameters to the template, and finally, std - namespace having collection of STL classes 11Standard Template Library

Basic Types of Iterators Random Access Iterator Bidirectional Iterator Forward Iterator Input Iterator Output Iterator 12Standard Template Library

13Standard Template Library

Introduction Used generically across a variety of containers. STL provides many algorithms to manipulate containers. STL provides approximately 70 standard algorithms that operate on container elements only indirectly through iterators. Many algorithms operate on sequence of elements defined by pairs of iterators It is possible to create new algorithms that operate in a similar fashion so they can be used with the STL containers and iterators. 14Standard Template Library

Basic Types of Algorithms Mutating Sequence Algorithms like copy(), remove(), replace(), fill(), swap(), etc., Non Modifying sequence Algorithms like find(), count(),search(), mismatch(), and equal() Numerical Algorithms accumulate(), partial_sum(), inner_product(), and adjacent_difference() 15Standard Template Library

16Standard Template Library

17