1 Designing Efficient Libraries Alexander Stepanov July 21, 2003 Alexander Stepanov July 21, 2003.

Slides:



Advertisements
Similar presentations
Chapter 21 The STL (maps and algorithms) Bjarne Stroustrup
Advertisements

Chapter 20 The STL (containers, iterators, and algorithms)
Chapter 7 Completing a Program
Chapter 18 Vectors and Arrays
SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
Chapter 20 The STL (containers, iterators, and algorithms) John Keyser’s Modifications of Slides by Bjarne Stroustrup
Object Oriented Programming Lect. Dr. Daniel POP Universitatea de Vest din Timişoara Facultatea de Matematică şi Informatică.
Vectors, lists and queues
TEMPLATES Lecture Presented By SHERY KHAN Object Orienting Programming.
C++ Templates. What is a template? Templates are type-generic versions of functions and/or classes Template functions and template classes can be used.
Interfaces A Java interface is a collection
1 STL and Its Design Principles Alexander Stepanov.
Generic Programming and Formal Methods David R. Musser Rensselaer Polytechnic Institute.
Alex Stepanov Zander Kelley CSCE 221H Spring 2014.
Generic Programming in the STL and Beyond David R. Musser Rensselaer Polytechnic Institute.
The Standard Template Library provides the framework for building generic, highly reusable algorithms and data structures A reference implementation of.
More on the STL vector list stack queue priority_queue.
OOP Etgar 2008 – Recitation 101 Object Oriented Programming Etgar 2008 Recitation 10.
 2006 Pearson Education, Inc. All rights reserved. Templates (again)CS-2303, C-Term Templates (again) CS-2303 System Programming Concepts (Slides.
The Standard Template Library. Books on standard C++ library Nicolai M. Josuttis: C++ Standard Library: A tutorial and Reference, 1st, Pearson 1999, Nicolai.
Generic programming starts with algorithms. Lift Minimal requirements: works with maximal family of types Concrete algorithm: requires specific data type.
Rossella Lau Lecture 1, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 1: Introduction What this course is about:  Data.
C + 1 == C++ ce153c Introduction2programming © 2006 NematAllah Ahmadyan.
Standard Template Library C++ introduced both object-oriented ideas, as well as templates to C Templates are ways to write general code around objects.
Sorting and Vectors Mechanism for representing lists JPC and JWD © 2002 McGraw-Hill, Inc. Modified by S. Sudarshan.
Adaptive Parallel Sorting Algorithms in STAPL Olga Tkachyshyn, Gabriel Tanase, Nancy M. Amato
PRESENTED BY: RAJKRISHNADEEPAK.VUYYURU SWAMYCHANDAN.DONDAPATI VINESHKUMARREDDY.LANKA RAJSEKHARTIRUMALA KANDURI ALAN.
Generic Programming Using the C++ Standard Template Library.
Templates ©Bruce M. Reynolds & Cliff Green1 C++ Programming Certificate University of Washington Cliff Green.
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.
Copyright 2006, The Ohio State University Introduction to C++ Templates l C++ Function Templates l C++ Class Templates.
Exceptions & Templates
1 The Standard Template Library Drozdek Section 3.7.
Algorithms CNS 3370 Copyright 2003, Fresh Sources, Inc.
Introduction to Templates and Standard Template Library 1.
Object-Oriented Programming (OOP) Lecture No. 41
Motivation for Generic Programming in C++
Sorting Algorithms Sections 7.1 to 7.4.
Introduction to Generic Programming in C++
Regarding homework 9 Many low grades
Programming with ANSI C ++
Standard Template Library
Types for Programs and Proofs
Standard Template Library (STL)
STL Common tools for C++.
STACKS AND QUEUES UNIT 2 DS THROUGH C++.
Starting Out with C++ Early Objects Eighth Edition
جامعة البحر الاحمر كلية العلوم التطبيقية قسم الفيزياء التطبيقية الفصل الداسي الثاني IIالمقرر: حاسوب د. خالد عثمان العالم.
Introduction to the Standard Template Library
C++ STL Vector Container
CS212: Object Oriented Analysis and Design
Generic Programming Karl Lieberherr 12/1/2018 Generic Programming.
priority_queue<T>
جامعة البحر الاحمر كلية العلوم التطبيقية قسمي الحاسوب وتقنية المعلومات الفصل الداسي الثاني المقرر: اساليب برمجة 1 محاضرة رقم 1 د. خالد عثمان العالم.
Containers, Iterators, Algorithms, Thrust
Templates. Templates Example: Swap Template Mechanism.
Standard Template Library Find
Standard Template Library Model
Containers and the Standard Template Library (STL)
Data structures and algorithms
Templates (again) Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Design Patterns Difficult to describe abstractly Elements:
The Standard Template Library
Standard Template Library
the Standard Template Library
Data Structures and ADTs
Standard Template Library
Lecture 8: Introduction to C++ Templates and Exceptions
Advanced Program Design with C++
Presentation transcript:

1 Designing Efficient Libraries Alexander Stepanov July 21, 2003 Alexander Stepanov July 21, 2003

2 What is STL? STL is large, systematic, clean, formally sound, comprehensible, elegant, and efficient framework Bjarne Stroustrup, AT&T STL looks like the machine language macro library of an anally retentive assembly language programmer Pamela Seymour, Leiden University

3 Design goals  Well structured, comprehensive library of useful components  Every component is as abstract as theoretically possible and as efficient as its hand-coded, non- abstract version in C

4 How fast is fast? Data typeqsorthand codedNumerical Recipes STL int short byte float double

5 Lightweight interfaces int array[1000]; … sort(array, array ); // use only parts you need // works with C arrays

6 Ability to customize // need descending order? sort(array, array , greater ()); // need to sort the second half only? sort(array + 500, array );

7 Many related algorithms  partial_sort, partial_sort_copy  find first 10 out of 1000  stable_sort  sort by name, then by department  min_element, max_element, nth_element

8 Complexity specifications  Operation counts for algorithms  Asymptotic complexity at the interface level (see in particular, )

9 Controversial points  not Object Oriented  Copy semantics  Unsafe

10 Performance pitfall 1 vector v; Record new_record; while (get_record(new_record)) { v.reserve(v.size() + 1); v.push_back(new_record); }

11 Performance pitfall 2 deque d( ); sort (d.begin(), d.end());

12 Bizarre algorithms template void sort(Iter f, Iter l) { while(next_permutation(f, l)); } template void maybe_sort(Iter f, Iter l) { while(!is_sorted(f, l)) random_shuffle(f, l); }

13 ConclusionsConclusions  To get performance, design for performance  Performance tools require study and thinking  Poor performance could mean sloppy design