CS212: Object Oriented Analysis and Design

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

. 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.
C++ Templates. What is a template? Templates are type-generic versions of functions and/or classes Template functions and template classes can be used.
Data Structures: A Pseudocode Approach with C
C++ Sets and Multisets Set containers automatically sort their elements automatically. Multisets allow duplication of elements whereas sets do not. Usually,
Week 5 - Associative Containers: sets and maps. 2 2 Main Index Main Index Content s Content s Container Types Sequence Containers Adapter Containers Associative.
COMP 171 Data Structures and Algorithms Tutorial 1 Template and STL.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
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.
Basic C++ Sequential Container Features
Templates and the STL.
Writing Your Own STL Container Ray Lischner
Chapter 19 - basic definitions - order statistics ( findkth( ) ) - balanced binary search trees - Java implementations Binary Search Trees 1CSCI 3333 Data.
Data Structures Using C++ 2E
Containers Overview and Class Vector
DATA STRUCTURES AND ALGORITHMS Lecture Notes 12 Prepared by İnanç TAHRALI.
PRESENTED BY: RAJKRISHNADEEPAK.VUYYURU SWAMYCHANDAN.DONDAPATI VINESHKUMARREDDY.LANKA RAJSEKHARTIRUMALA KANDURI ALAN.
Generic Programming Using the C++ Standard Template Library.
C++ STL CSCI 3110.
STL multimap Container. STL multimaps multimaps are associative containers –Link a key to a value –AKA: Hashtables, Associative Arrays –A multimap allows.
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.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
CS212: Object Oriented Analysis and Design Lecture 24: Introduction to STL.
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.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
STL – Standard Template Library L. Grewe. 2 Goals Lots of important algorithms, data structures in CS using Templates. is a software library partially.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
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.
CS212: Object Oriented Analysis and Design Lecture 26: STL Containers.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
CSCI  Sequence Containers – store sequences of values ◦ vector ◦ deque ◦ list  Associative Containers – use “keys” to access data rather than.
Main Index Contents 11 Main Index Contents Sets Defined by a key along with other data Sets Defined by a key along with other data Key-Value Data Key-Value.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
Final Exam Review COP4530.
Object-Oriented Programming (OOP) Lecture No. 41
Standard Template Library
CS212: Object Oriented Analysis and Design
C++ Programming:. Program Design Including
Top 50 Data Structures Interview Questions
Standard Template Library
CSCI 210 Data Structures and Algorithms
Data Abstraction & Problem Solving with C++
Standard Template Library
Standard Template Library (STL)
Object Oriented Programming COP3330 / CGS5409
Associative Structures
Chapter 18: Linked Lists.
Final Exam Review COP4530.
priority_queue<T>
Recitation Outline C++ STL associative containers Examples
Standard Template Library Model
Doubly Linked List Implementation
Chapter 17: Linked Lists.
Copyright © – Curt Hill STL List Details Copyright © – Curt Hill.
Iterators and STL Containers
Lecture 8 : Intro. to STL (Standard Template Library)
Standard Template Library
Doubly Linked List Implementation
Standard Template Library
Some Definitions vector, string, deque, and list are standard sequence containers. set, multiset, map, multimap, unordered_set, unordered_multiset, unordered_map.
CO4301 – Advanced Games Development Week 12 Using Trees
A dictionary lookup mechanism
Standard Template Library
Presentation transcript:

CS212: Object Oriented Analysis and Design Containers

STL Components STL Iterator Algorithm Container

STL: Lists Lists are sequence containers Allow constant time insert and erase operations anywhere within the sequence Iteration in both directions. List containers are implemented as doubly-linked lists template < class T, class Alloc = allocator<T> > class list;

Drawbacks Direct access to the elements by their position is missing It does not have an operator[ ] Takes linear time in the distance between a known location and target location Consume some extra memory to keep the linking information associated to each element

Container properties Sequence Elements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by their position in this sequence. Doubly-linked list Allowing constant time insert and erase operations before or after a specific element (even of entire ranges), But no direct random access. Allocator-aware The container uses an allocator object to dynamically handle its storage needs.

List Constructors Constructs an empty list explicit list(const Allocator &a = Allocator( ) ); explicit list(size_type num, const T &val = T ( ), const Allocator &a = Allocator( )); list(const list<T, Allocator> &ob); template <class InIter>list(InIter start, InIter end, Constructs a list that has num elements with the value val Constructs a list that contains the same elements as ob Constructs a list contains the elements in the range specified by the iterators start and end

Common operations on list Create a list Insert an element: push_front() and push_back() Sort Robustness … Performance comparison

Map Supports an associative container Unique keys are mapped with values Once a value has been stored, can be retrieved by using key The power of a map is that you can look up a value given its key A map can hold only unique keys. Duplicate keys are not allowed.

Map constructors explicit map (const Comp &cmpfn = Comp( ), Constructs an empty map explicit map (const Comp &cmpfn = Comp( ), const Allocator &a = Allocator( ) ); map (const map<Key, T, Comp, Allocator> &ob); template <class InIter> map (InIter start, InIter end, const Comp &cmpfn = Comp( ), const Allocator &a = Allocator( )); Constructs a map that contains the same elements as ob Constructs a map that contains the elements in the range specified by the iterators start and end

Set A container that accept only one of each thing placed in it It also sorts the elements Sorting isn’t intrinsic to the conceptual definition of a set But the STL set stores its elements in a balanced binary tree to provide rapid lookups, Thus producing sorted results when traversed