What is generic programming? The essence of the generic programming approach is concept development: systematic classification of computing components.

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

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.
1 STL and Its Design Principles Alexander Stepanov.
C++ Sets and Multisets Set containers automatically sort their elements automatically. Multisets allow duplication of elements whereas sets do not. Usually,
Generic Programming in the STL and Beyond David R. Musser Rensselaer Polytechnic Institute.
. 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)
Standard Template Library (STL) Overview – Part 1 Yngvi Bjornsson.
Data Structures Using C++1 Chapter 13 Standard Template Library (STL) II.
. STL: C++ Standard Library. Main Ideas u General purpose: generic data structures & algorithms, templates u Flexibility: Allows for many combinations.
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.
Writing Your Own STL Container Ray Lischner
Spring 2010 Advanced Programming Section 1-STL Computer Engineering Department Faculty of Engineering Cairo University Advanced Programming Spring 2010.
1 Concepts: Linguistic Support for Generic Programming in C++ Douglas Gregor Jeremy Siek Gabriel Dos Reis Jaakko Järvi Bjarne Stroustrup Andrew Lumsdaine.
Data Structures Using C++ 2E
Containers and Iterators CNS 3370 Copyright 2003, Fresh Sources, Inc.
CNS  Sequences  vector,deque,list,(string),forward_list  Container Adapters  queue, stack, priority_queue  Associative Containers  set, unordered_set.
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
 2006 Pearson Education, Inc. All rights reserved Standard Template Library (STL)
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)
The C++ Standard Template Library. What is STL A subset of the standard C++ library –The string class is not part of it! 3 major components –Algorithms.
Data Structures Using C++ 2E Chapter 13 Standard Template Library (STL) II.
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
We can’t walk on water, Trinity Software computer simulation. but we can produce the.
Software Design 1.1 Tapestry classes -> STL l What’s the difference between tvector and vector  Safety and the kitchen sink What happens with t[21] on.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 22: Standard Template Library (STL)
CSE 332: C++ STL containers Review: C++ Standard Template Library (STL) The STL is a collection of related software elements –Containers Data structures:
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.
1 Iterators Good reference site:
CS 403, Class 23Slide #1 CS Programming Languages Class 23 November 16, 2000.
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.
STL – Standard Template Library L. Grewe. 2 Goals Lots of important algorithms, data structures in CS using Templates. is a software library partially.
Standard Template Library (STL) - Use Vector and Deque
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.
Algorithms CNS 3370 Copyright 2003, Fresh Sources, Inc.
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.
Final Exam Review COP4530.
CS212: Object Oriented Analysis and Design
COP 3530 Data Structures & Algorithms
STL – Standard Template Library
Standard Template Library (STL)
Starting Out with C++ Early Objects Eighth Edition
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
Programming with Concepts
Chapter 22: Standard Template Library (STL)
CS212: Object Oriented Analysis and Design
Final Exam Review COP4530.
Generic Programming Karl Lieberherr 12/1/2018 Generic Programming.
Containers, Iterators, Algorithms, Thrust
Design Patterns Difficult to describe abstractly Elements:
STL Библиотека стандартных шаблонов
Standard Template Library
Standard Template Library
Jim Fawcett CSE687 – Object Oriented Design Spring 2002
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:

What is generic programming? The essence of the generic programming approach is concept development: systematic classification of computing components according to their formal requirements But what is a concept? Generic Programming: Programming with Concepts

Concept= set of abstractions (e.g., types) Generic Programming= Programming with Concepts defined by a set of requirements {vector, deque, list, set, map hash_set, …} = Definition: Container refines Basic-container; uses Input-iterator; introduces begin(containers) -> iterators, end(containers) -> iterators, size(containers) -> naturals, empty(containers) -> bool; requires (for c: containers) size(c) = size(range(c, begin(c), end(c))), empty(c) = (size(c) = 0), valid(range(c, begin(c), end(c))). generic algorithmsalgorithms that work correctly for every abstraction in a concept = e.g., generic container algorithms: copy, for_each, equal, transform, accumulate, … and efficiently Container Concept e.g., Container Concept in Standard Template Library (STL)

Container Forward Container Sequence Front Insertion Sequence Back Insertion Sequence Reversible Container Random Access Container Associative Container List Vector Deque Front & Back Insertion Sequence Sorted A. C. Unique A. C. Multiple A. C. Hashed A. C. Unique Sorted A. C. Multiple Sorted A. C. Unique Hashed A. C. Multiple Hashed A. C. Simple A. C. Paired A. C. SetMultisetH. Set H. Multiset H. Multi- map H. Map Multimap Slist STL Container Concepts See also

Container Forward Container Sequence Front Insertion Sequence Back Insertion Sequence Reversible Container Random Access Container List Vector Deque Front & Back Insertion Sequence Slist STL Generic Algorithms on Forward Containers Requires input iterators Enables generic algorithms copy, for_each, equal, transform, … Requires forward iterators Enables find, merge, fill, replace, generate, remove, unique, rotate, … … Requires bidirectional iterators Enables reverse, partition, inplace_merge, … Requires random access iterators Enables sort, binary_search, random_shuffle, …

Container Forward Container Associative Container STL Concepts Input Iterator Output Iterator Forward Iterator Bidirectional Iterator Random Access Iterator AlgorithmFunctorAdaptor Input Algorithm Output Algorithm Forward Algorithm Bidirectional Algorithm Random Access Algorithm Unary Functor Binary Functor Binary Predicate Order Relation Iterator Adaptor

MTL Concepts STL Concepts ContainerIteratorAlgorithmFunctorAdaptor 2-D Iterator Matrix Sparse Matrix Dense Matrix Banded Matrix … Iterator Adaptor SparseDenseScaled … New Concepts in the Matrix Template Library Matrix Algorithm Matrix Vector Algorithm Matrix Algorithm

BGL Concepts STL Concepts ContainerIteratorAlgorithmFunctorAdaptor Graph Iterator Graph Incidence Graph Adj. Graph EdgeList Graph … New Concepts in the Boost Graph Library Graph Algorithms Visitor BFS Visitor DFS Visitor Uniform Cost Visitor …

Best to work upwards from experience with real problems Best to start with algorithms: what do they need for generality, correctness, and efficiency (as in STL, MTL, BGL, …) and, in advanced research, - reliability, - mobility, - real-time How Should We Attempt to Design and Implement Generic Computing Concepts?

Need advances in way we specify and organize performance properties, in addition to functionality Performance properties of components should be an integral part of concept requirements Raw material for performance descriptions: analytically derived bounds empirically observed performance data The Role of Performance