STL and Example.

Slides:



Advertisements
Similar presentations
Thrust & Curand Dr. Bo Yuan
Advertisements

Brown Bag #2 Advanced C++. Topics  Templates  Standard Template Library (STL)  Pointers and Smart Pointers  Exceptions  Lambda Expressions  Tips.
. 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.
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.
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
STL-Associative Containers. Associative Containers Sequence containers : "This is item 0, this is item 1, this is item 2…“ Associative containers : –
C++ STL CSCI 3110.
C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program.
COP 3530 Data Structures & Algorithms Discussion Session 3.
 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.
Ticket Booth Base Level 3 1. In the completed program, the ticket seller will: Select a venue from a menu of all venues. Select a show from a menu of.
1 Chapter 1 C++ Templates Sections 1.6 and Templates Type-independent patterns that can work with multiple data types –Generic programming –Code.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Managers and “mentors” identified on projects page. All member accounts created and projects populated.
Copyright © 2006 Pearson Addison-Wesley. All rights reserved Today’s Learning Objective  Standard Template Library.
STL: Maps Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
Engineering Problem Solving with C++, Second Edition, J. Ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 4 Working with Data Files.
C++ Review STL CONTAINERS.
A recap of the STL and more containers Plus an intro to string and file input and output! Lecture 8.
Collection types CS Chakrabarti Motivation  Thus far the only collection types we have used are vector and matrix  Problem #1: given an input.
Glenn Stevenson CSIS 113A MSJC CSIS 123A Lecture 3 Vectors.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
STL Associative Containers navigating by key. Pair Class aggregates values of two, possibly different, types used in associative containers defined in.
Issues in Transgender Primary Care
Put-call parity example 2
MAKING REAL THINGS HAPPEN IN CUBA
Ms. Driscoll’s class FOURTH GRADE! Welcome to We love Math
-KB5- Business Value Creations
Building Extension Task
Coordinator, Transition Services
Ch 5 Pt 3 (5-7 & 5-8) Portfolio Page -- Algebra 2
SURFACE HEAT TREATMENTS OF STEELS.
C++ CSCE 343.
Programming with ANSI C ++
Standard Template Library
Now with a speaking professor! (hopefully...)
CS Computer Science IA: Procedural Programming
Arrays An array in PHP is an ordered map
Standard Template Library (STL)
Functionality & Performance in Milestone 1
Parallel Arrays Parallel array =>Two or more arrays with the same number of elements used for storing related information about a collection of data. Example:
Today’s Learning Objective
COSC 1323 – Computer Science Concepts I
Vectors.
Compound Data CSCE 121 J. Michael Moore.
Perl Variables: Hash Web Programming.
STL - Algorithms.
Strings and Streams Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
C++ File Structure and Intro to the STL
CS106A, Stanford University
Recitation Outline C++ STL associative containers Examples
Standard Template Library Model
CISC/CMPE320 - Prof. McLeod
CS150 Introduction to Computer Science 1
Iterators and STL Containers
Vectors CSCE 121 J. Michael Moore.
Standard Template Library (STL)
C++ Standard Template Library CSE 333 Summer 2018
C++ File Structure and Intro to the STL
Tenth step for Learning C++ Programming
File Streams 12/09/13.
STL (Standard Template Library)
STL and Example.
C++ Programming: chapter 10 – STL
Standard C++ Library Part II.
An Introduction to STL.
Vectors CSCE 121.
ENERGY 211 / CME 211 Lecture 20 November 5, 2008.
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Standard Template Library
Presentation transcript:

STL and Example

Review <vector> Declaration: std::vector<T>vec = {initializer list} Access and modify: vec[index] = value Assignment of whole array: new_vec = vec Find size: vec.size() Extend: vec.push_back(val)

C++ Libraries – Dictionary or Associative Array Take two types first key and second is value. <key,value> Use as an array indexed by key values. <map> Whole container can be accessed in key order O(log n) for most operations <unordered_map> Accessing the whole container is possible but the order is not defined O(1) expected for most operations

<map> Declaration: std::map<T1,T2>my_map Access and modify: my_map[index] = value Assignment of whole array: new_map = my_map Find size: my_map.size() Find: my_map.find(key) Returns an iterator to a pair <key,value>

STL iterators and pair Iterators STL pair Acts like a pointer access the value with * or -> as with a pointer Used to interact with STL containers STL pair Two types <T1,T2> Access through public member variables first and second

Filestreams ofstream – Write to a file ifstream – Read from a file fstream – Read and write from a file Open the file fstream.open(filename) Close the file fstream.close()

Gradebook