Introduction to Generic Programming in C++

Slides:



Advertisements
Similar presentations
SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
Advertisements

Chapter 20 The STL (containers, iterators, and algorithms) John Keyser’s Modifications of Slides by Bjarne Stroustrup
CSE 332: C++ overview CSE 332 Overview and Structure CSE 332 emphasizes studio-based active learning –Introductory lecture material followed by hands-on.
CSE 332: C++ Algorithms I The C++ Algorithm Libraries A standard collection of generic algorithms –Applicable to various types and containers E.g., sorting.
1 STL and Its Design Principles Alexander Stepanov.
Cpt S 122 – Data Structures Course Introduction
OBJECT ORIENTED ANALYSIS & DESIGN Vassilka Kirova Department of Computer & Information Science NJIT.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
CSE 332: C++ templates and generic programming I Motivation for Generic Programming in C++ We’ve looked at procedural programming –Reuse of code by packaging.
Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns.
CSE 332: C++ STL algorithms C++ STL Algorithms Generic algorithms –Apply to a wide range of types E.g., sorting integers ( int ) vs. intervals ( pair )
Copyright © 2002, Systems and Computer Engineering, Carleton University Intro.ppt * Object-Oriented Software Development Unit 1 Course.
CSE 332: C++ Algorithms II From Last Time: Search with Generic Iterators Third generalization: separate iterator type parameter We arrive at the find algorithm.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science Washington University, St. Louis
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Unified Modeling Language, Version 2.0
Early Adopter: Integrating Concepts from Parallel and Distributed Computing into the Undergraduate Curriculum Eileen Kraemer Computer Science Department.
Computer Concepts 2014 Chapter 12 Computer Programming.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Standard Template Library (STL)
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
The Next Generation Science Standards: 4. Science and Engineering Practices Professor Michael Wysession Department of Earth and Planetary Sciences Washington.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
CSE 332: C++ template examples Concepts and Models Templates impose requirements on type parameters –Types that are plugged in must meet those requirements.
Overview of C++ Templates
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
CSE 332: C++ STL iterators What is an Iterator? An iterator must be able to do 2 main things –Point to the start of a range of elements (in a container)
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Huang-Ming Huang, Shih-Ling Chen, Sajeeva Pallemulle.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
CSE 332: C++ templates and generic programming II Review: Concepts and Models Templates impose requirements on type parameters –Types that are plugged.
Basic Characteristics of Object-Oriented Systems
1 Welcome Alireza Humber College Lecture 1 Game 540 Alireza
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
C++11 Atomic Types and Memory Model
Motivation for Generic Programming in C++
Examples (D. Schmidt et al)
Programming paradigms
Event Handling Patterns Asynchronous Completion Token
Design Patterns (Chapter 6 of Text Book – Study just 8)
Chapter 5:Design Patterns
Systems Analysis and Design With UML 2
Midterm Review David Ferry, Chris Gill
Wrapper Façade Pattern
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Object-Orientated Programming
The C++ Algorithm Libraries
Chapter 19: Interfaces and Components
INFS 6225 – Object-Oriented Systems Analysis & Design
.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017.
The Active Object Pattern
CSCI N207 Data Analysis Using Spreadsheet
Introduction to Computer Science for Majors II
Templates (again) Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Monitor Object Pattern
Chapter 19: Interfaces and Components
Chapter 19: Interfaces and Components
Testing and Debugging Concurrent Code
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Standard Template Library
Software Engineering Basics
Interfaces and Components
Standard Template Library
Cs212: Data Structures Lecture 7: Tree_Part1
Presentation transcript:

Introduction to Generic Programming in C++ E81 CSE 532S: Advanced Multi-Paradigm Software Development Introduction to Generic Programming in C++ Chris Gill Department of Computer Science Washington University, St. Louis cdgill@cs.wustl.edu Title slide

Each Paradigm Has a Particular View “Computer programming is largely a matter of algorithms and data structures.” Austern pp. 3 (Generic Programming Paradigm) Object-based might say “methods and data” OO might say “inheritance and polymorphism” Patterns might say “design forces and contexts” And so forth …

What is the STL? An abstract library of concepts A formal hierarchy of software requirements A library of interchangeable modules Algorithms Containers Iterators Function objects, and much more A flexible and efficient software framework An extensible platform for software development

What is Generic Programming? An abstraction technique for algorithms Argument types are as general as possible Separates algorithm steps & argument properties What GoF design pattern does this resemble? Type requirements can be specified, systematized Can cluster requirements into abstractions Termed “concepts” Concepts can refine other concepts Captures relationships between concepts Analogy to inheritance hierarchies A type that meets a concept’s requirements Is a “model” of the concept Can be plugged in to meet that set of requirements

Generic Algorithm Example STL linear search (based on Austern pp. 13): template <typename Iterator, typename T> Iterator find2 (Iterator first, Iterator last, const T & value) { while (first != last && *first != value) { ++first; } return first; A generic algorithm Searches any one-dimensional sequence of elements, for any type on which the operators work