C++ Programming: chapter 10 – STL

Slides:



Advertisements
Similar presentations
Copyright © 2002 Pearson Education, Inc. Slide 1.
Advertisements

Chapter 19 Standard Template Library. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Iterators Constant and mutable.
1 Linked lists Sections 3.2, 3.3, 3.5 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors.
Hold data and provide access to it. Random-access containers: -Allow accessing any element by index -arrays, vectors Sequential containers: -Allow accessing.
SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
Vectors, lists and queues
. STL: C++ Standard Library (continued). STL Iterators u Iterators are allow to traverse sequences u Methods  operator*  operator->  operator++, and.
COMP 171 Data Structures and Algorithms Tutorial 1 Template and STL.
More on the STL vector list stack queue priority_queue.
Standard Template Library. Homework List HW will be posted on webpage Due Nov 15.
Standard Template Library (STL) Overview – Part 1 Yngvi Bjornsson.
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.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Data Structures Using C++ 2E
1 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 12 Prepared by İnanç TAHRALI.
Chapter 9: Part 2: Vectors + Maps and STL Overview JPC and JWD © 2002 McGraw-Hill, Inc. Modified by S. Sudarshan and A. Ranade.
Templates Mark Hennessy Dept Computer Scicene NUI Maynooth C++ Workshop 18 th – 22 nd September 2006.
Chapter 9: Part 2: Vectors + Maps and STL Overview JPC and JWD © 2002 McGraw-Hill, Inc. Modified by S. Sudarshan.
Friends & Standard Template Library CSCI3110 Advanced Data Structures Lecturer: Dr. Carroll and Nan Chen.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
 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)
Computer Science and Software Engineering University of Wisconsin - Platteville 11.Standard Template Library Yan Shi CS/SE 2630 Lecture Notes.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
A gentle introduction to the standard template library (STL) Some references:
C++ Review STL CONTAINERS.
Glenn Stevenson CSIS 113A MSJC CSIS 123A Lecture 3 Vectors.
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.
Copyright © Curt Hill STL Priority Queue A Heap-Like Adaptor Class.
CSCI  Sequence Containers – store sequences of values ◦ vector ◦ deque ◦ list  Associative Containers – use “keys” to access data rather than.
Object-Oriented Programming (OOP) Lecture No. 41
Standard Template Library
C++ Standard Template Library
Introduction to olympic programming
Data Structures Interview Questions.
Standard Template Library
Vectors Holds a set of elements, like an array
CSCE 210 Data Structures and Algorithms
Chapter 8 Arrays, Strings and pointers
Standard Template Library (STL)
Collections Intro What is the STL? Templates, collections, & iterators
What remains Topics Assignments Final exam
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
Basic Data Structures.
An Introduction to Pointers
Abstract Data Types Iterators Vector ADT Sections 3.1, 3.2, 3.3, 3.4
Object Oriented Programming COP3330 / CGS5409
Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors
Introduction to C++ STL
priority_queue<T>
Erasmus Exchange in Ionian University
Chapter 9 One-Dimensional Arrays
Chapter 17: Linked Lists.
Lists - I The List ADT.
Lists - I The List ADT.
Copyright © – Curt Hill STL List Details Copyright © – Curt Hill.
Iterators and STL Containers
Lecture 8 : Intro. to STL (Standard Template Library)
Standard Template Library (STL)
STL Библиотека стандартных шаблонов
STL (Standard Template Library)
Standard Template Library
Collections Intro What is the STL? Templates, collections, & iterators
Standard Template Library
An Introduction to STL.
Chapter 3 Lists, Stacks, and Queues
8.3 Vectors Copyright © 2008 Pearson Addison-Wesley. All rights reserved. 1.
Chapter 9 – Sets and Maps 9.1 Associative Container
Presentation transcript:

C++ Programming: chapter 10 – STL 2018, Spring Pusan National University Ki-Joune Li http://lik.pnu.kr

Sample #include <iostream> #include <vector> using namespace std; int main() { vector<int> example; example.push_back(3); example.push_back(10); example.push_back(33); for(int x=0; x<example.size(); x++) cout<<example[x]<<" "; if(!example.empty()) example.clear(); vector<int> another_vector; another_vector.push_back(10) if(example==another_vector) example.push_back(20); for(int y=0; y<example.size(); y++) cout<<example[y]<<" "; return 0; }

STL – Standard Template Library Most C++ compilers provide a convenient container template. Data Types Useful Operations Based on Template Data Structure STL Name Library to #include Type Dynamic Array vector <vector> Sequence Linked List list <list> Stack stack <stack> Container Adapter Queue queue <queue> Binary Tree set <set> Associate Hash Table map <map> Max Heap priority_queue

What is container Contains elements (more than one) Basic Operations on Container

Basic Operations Types Operation array vector list set Iterator begin end Capacity size empty max_size Access front back operator[] X Modifier assign insert erase push_back pop_back clear

Sample – using Iterator #include <iostream> #include <set> using namespace std; int main() { set<int> mySet; set<int>::iterator it; for(int i=0;i<5;i++) mySet.insert(it, i*10); for(it=mySet.begin(); it!=mySet.end();it++) cout<<*it<<" "; return 0; }