CSCI-383 Object-Oriented Programming & Design Lecture 30.

Slides:



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

Object Oriented Programming Lect. Dr. Daniel POP Universitatea de Vest din Timişoara Facultatea de Matematică şi Informatică.
Stacks, Queues, and Deques. 2 A stack is a last in, first out (LIFO) data structure Items are removed from a stack in the reverse order from the way they.
Lecture 5 Sept 15 Goals: stacks Implementation of stack applications Postfix expression evaluation Convert infix to postfix.
Templates and the STL Bryce Boe 2012/09/10 CS32, Summer 2012 B.
The Standard Template Library – part 2. auto_ptr Regular pointers may cause memory leaks Regular pointers may cause memory leaks void f() { SomeClass.
Main Index Contents 11 Main Index Contents Model for a Queue Model for a Queue The Queue The Queue ADTQueue ADT (3 slides) Queue ADT Radix Sort Radix Sort.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Quick Overview of STL STL = Standard Template Library Main concept : Container, Iterator Application : Linked list, Stack etc.
TCSS 342, Winter 2005 Lecture Notes
Basic C++ Sequential Container Features
CS 240: Data Structures Thursday, July 12 th Lists, Templates, Vector, Algorithms.
Stacks, Queues, and Deques
Data Structures Data structures permit the storage of related data for use in your program. –Arrays.
1.7 Arrays academy.zariba.com 1. Lecture Content 1.Basic Operations with Arrays 2.Console Input & Output of Arrays 3.Iterating Over Arrays 4.List 5.Cloning.
Data Structures: CSCI 362 – Stack Implementation Data Structures: CSCI 362 – Stack Implementation lecture notes adapted from Data Structures with C++ using.
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.
Containers Overview and Class Vector
Programming Languages and Paradigms Object-Oriented Programming (Part II)
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Standard Template Library (STL)
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 26: Exam 2 Preview.
C++ STL CSCI 3110.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 18 Stacks and Queues.
STL multimap Container. STL multimaps multimaps are associative containers –Link a key to a value –AKA: Hashtables, Associative Arrays –A multimap allows.
Data structures Abstract data types Java classes for Data structures and ADTs.
Templates code reuse - inheritance - template classes template classes - a class that is not data-type specific - eg. a class of Array of any type - intArray,
1. The term STL stands for ? a) Simple Template Library b) Static Template Library c) Single Type Based Library d) Standard Template Library Answer : d.
Friends & Standard Template Library CSCI3110 Advanced Data Structures Lecturer: Dr. Carroll and Nan Chen.
C++ How to Program, 9/e © by Pearson Education, Inc. All Rights Reserved.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Introduction to the Standard Template Library (STL) A container class holds a number of similar objects. Examples: –Vector –List –Stack –Queue –Set –Map.
Lists Chapter 8. 2 Linked Lists As an ADT, a list is –finite sequence (possibly empty) of elements Operations commonly include: ConstructionAllocate &
CS212: Object Oriented Analysis and Design Lecture 24: Introduction to STL.
The ADT Table The ADT table, or dictionary Uses a search key to identify its items Its items are records that contain several pieces of data 2 Figure.
OOP using C Abstract data types How to accomplish the task??? Requirements Details Input, output, process Specify each task in terms of input.
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.
STL – Standard Template Library L. Grewe. 2 Goals Lots of important algorithms, data structures in CS using Templates. is a software library partially.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
Copyright © 2009 – Curt Hill Standard Template Library An Introduction.
C++ Review STL CONTAINERS.
CSCI-383 Object-Oriented Programming & Design Lecture 25.
1 Chapter 3 Lists, Stacks, and Queues Reading: Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
CSCI 383 Object-Oriented Programming & Design Lecture 25 Martin van Bommel.
Glenn Stevenson CSIS 113A MSJC CSIS 123A Lecture 3 Vectors.
Chapter 18 Introduction to Custom Templates C++ How to Program, 9/e ©2016 by Pearson Education, Inc., Hoboken, NJ. All Rights Reserved. Instructor Note:
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
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.
Prime Numbers Lecture L4.4 Sieve of Eratosthenes.
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.
Templates 3 Templates and type parameters The basic idea templates is simple: we can make code depend on parameters, so that it can be used in different.
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.
Object-Oriented Programming (OOP) Lecture No. 41
CS212: Object Oriented Analysis and Design
C++ Programming Standard Template Library Homework 5,6,7.
Sorted Linked List Same objective as a linked list, but it should be sorted Sorting can be custom according to the type of nodes Offers speedups over non-sorted.
Standard Template Library (STL)
STACKS AND QUEUES UNIT 2 DS THROUGH C++.
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
Final Exam Review COP4530.
C++ STL Stack, Queue, and Deque
Tenth step for Learning C++ Programming
Stacks, Queues, and Deques
Standard Template Library
Presentation transcript:

CSCI-383 Object-Oriented Programming & Design Lecture 30

Adaptor Containers  They are not first-class containers Do not provide the actual data structure implementation in which elements can be stored Provide restricted subset of container functionality, do not support iterators  A benefit of an adaptor class is that you can choose an appropriate underlying data structure (e.g., by default, a stack is implemented with a deque, but this can be changed by second argument in constructor, e.g., vector instead of deque )

Adaptor Containers  The STL provides three adaptor containers stack queue priority_queue  All three adaptor classes provide member functions push and pop that properly insert an element into each adaptor  Handout #26 Handout #26  Handout #27 Handout #27  Handout #28 Handout #28

bitset  A special container designed to store bits (i.e., elements with only two possible values: 0 or 1, true or false,...)  Very useful for representing a set of bit flags  Very similar to a regular array, but optimizing for space allocation Each element occupies only one bit, which is eight times less than the smallest elemental type in C++ (i.e., char )  bitset s are fixed in size at compile time (i.e., unlike vector which allows for dynamic resizing)

Sieve of Eratosthenes  A simple and ancient algorithm for finding all prime numbers up to a specified integer Created by Eratosthenes, an ancient Greek mathematician  ALGORITHM (Done in class)

Sieve of Eratosthenes with bitset  Handout #29 Handout #29