CS107L Handout 04 Autumn 2007 October 19, 2007 Custom STL-Like Containers and Iterators
|
|
- Aileen Quinn
- 7 years ago
- Views:
Transcription
1 CS107L Handout 04 Autumn 2007 October 19, 2007 Custom STL-Like Containers and Iterators This handout is designed to provide a better understanding of how one should write template code and architect iterators to traverse containers. The entire discussion centers on the design and implementation of a singly linked list something that is officially included in the STL. However, we rewrite a subset of that functionality here, because the linked list is the least complicated class of all classes requiring custom iterator implementations. Let s get to it. Design of mylist to look and feel like the STL list class If we re going to have a linked list, then there s no denying the need for a link list node. class mylist; class mylist_iterator; // forward declare // forward declare class mylist_node friend class mylist<t>; friend class mylist_iterator<t>; mylist_node(const T& t, mylist_node<t> *next) : elem(t), next(next) ~mylist_node() delete next; T elem; mylist_node<t> *next; ; If, for just a moment, you rid of the constructor, you reduce the mylist_node to nothing more than a normal struct that just happens to mark everything as private. Naturally, to mark everything as private is to block everyone out, and for the most part, that s what we want here. However, mylist, mylist_node, and mylist_iterator are clearly intertwined, so the mylist_node<t> class allows any instance of mylist<t> and mylist_iterator<t> to examine the private data of a mylist_node<t> instance. This permission comes in the form of an explicit friendship statement placed at the front of the mylist_node definition.
2 2 Some key (or at least interesting) observations: 1. The public and private keywords have absolutely no influence over friendship. The very fact that the mylist_node granted friendship is enough to give all mylist and mylist_iterator full access to everything mylist_node-related. Note that the friendship is being offered to the classes themselves. That means that all instance and class methods have full access to any instance field of the mylist_node specifically, mylist and mylist_iterators can directly access any and all private data members and, had there been any, call any private methods as well. 2. Understand that the friendship is being granted to classes embracing the same exact type. mylist_node<string> grants friendship to mylist<string>, mylist_node<film *> grants friendship to mylist<film *>, and so forth. Technically, mylist_node<string> couldn t give a flying feather about mylist<film *>, so it sees no reason to grant friendship to all things mylist just mylist<string>. This should be clear, because the lines granting friendship include the <T>. friend class mylist<t>; friend class mylist_iterator<t>; 3. I chose to inline the implementation of the constructor and destructor, but I m only getting away with it here because there are so short and so relatively obvious. Had I preferred to place the implementations in the corresponding.cc file instead, I d have to have written them as follows: mylist_node<t>::mylist_node(const T& t, mylist_node<t> *next) : elem(t), next(next) // nothing needed, as everything is taken care of by the initialization list mylist_node<t>::~mylist_node() delete next; 4. Remember that the compiler automatically generates a copy constructor and an operator= method for us if we don t explicitly mention it in the class definition. Since we don t mention either here, we get those compilersynthesized versions (and they re automatically public).
3 Who would have thought that the mylist_node template class could be so very interesting? Let s start small and pretend that anything and everything relying on the existence of a true iterator type isn t included. class mylist mylist() : head(null), tail(null) ~mylist() delete head; bool empty() const return head == NULL; void push_back(const T& elem); mylist_node<t> *head, *tail; ; This doesn t even come close to the real linked list, but my ultimate goal here isn t to remind you what a linked list should do and how it works, but rather to motivate and implement an iterator. The mechanics of threading together a linked list is either old hat by now, or if not, can be reviewed in a matter of 15 minutes. The only difference between our linked list and the ones you ve dealt with in previous courses is the language we re building them in. The logistics of next pointers and NULL checks and whatnot are exactly the same. Notice I ve inlined the implementation of the constructor, the destructor, and the empty method. Here s what the mylist.cc file would look like if this were all mylist was defined to be. void mylist<t>::push_back(const T& elem) mylist_node<t> *newnode = new mylist_node<t>(elem, NULL); if (head == NULL) head = newnode; else tail->next = newnode; tail = newnode; The details of linked list insertion and deletion are always tricky, no matter what language they re in. If you doubt the implementation, then you should trace each method to ensure that all cases (empty list, list of length one, and all other lists) are properly handled. The most interesting element of the implementation at least from a C++ standpoint is the call to the mylist_node<t> constructor a call that s permitted only because the mylist class was granted that friendship mentioned earlier. Now that we have the basics of the linked list in place, it s high time we introduce the iterator so that built-in STL algorithms like for_each and find can traverse the elements of our mylist from front to back and making it appear as if the elements 3
4 inside the mylist are all laid out sequentially in memory. A terribly bad design would extend our current definition of the mylist class to include very buggy implementations of begin and end methods. Buggy, buggy, buggy, buggy! class mylist typedef T * iterator ; mylist() : head(null), tail(null) ~mylist(); bool empty() const return (head == NULL); void push_back(const T& elem); iterator begin () return (head == NULL? NULL : &head->elem); iterator end () return NULL; 4 ; mylist_node<t> *head, *tail; Such an implementation would assume that we ve absolutely no other choice for the typedef. If begin needs to return the 'address' of the first element and this 'address' should respond to * and ++ as a true pointer would, one might think there s really nothing else we can do. Perhaps it s the best that can be done; but if so, then this whole iterator thing would be pretty lame particularly lame here, since there s no way the individual elements of a list could possibly be accessed by an iterator that assumes all elements are organized side by side in memory. To drive this point home, consider the following: mylist<string> ivies; ivies.push_back("harvard"); ivies.push_back("yale"); ivies.push_back("princeton"); ivies.push_back("penn"); mylist<string>::iterator begin = ivies.begin(); mylist<string>::iterator end = ivies.end(); while (begin!= end) if (*begin == "Stanford") cout << "Stanford s an Ivy." << endl; return; ++begin; cout << "They re all snobs anyway." << endl;
5 Algorithmically, the code snippet is sound, and yet it doesn t work in fact, it seg faults. The blame can t be pinned on the code snippet itself, but rather the current definition of the mylist<string>::iterator. How can a local string * that s all the iterator is in this example behave any differently than a regular pointer? All those ++begin instructions are going to advance the pointer through memory as if there s an array of strings there, and that s just not the case. The iterator doesn t know how to advance to the next element in the sequence, because the instructions it follows to advance operator++ being that instruction just tell it to march sizeof(string) bytes ahead. The iterator we want here is something that knows how to update itself to point to the next element in the list. A normal pointer can t do that, but a class that responds to clever implementations of operator* and operator++ can. The idea of returning a class as an iterator seems a little off. However, as long as the type being returned responds to pointer syntax and exhibits normal pointer semantics, we shouldn t really care whether the iterator is a true pointer or something that just pretends to be. We re interested in appearances once again, it all comes down to looks. Shallow! 5 At this point, we can update the mylist template to export a new iterator type one that has a better chance of visiting all of the nodes: class mylist typedef mylist_iterator<t> iterator ; mylist() : head(null), tail(null) ~mylist() delete head; bool empty() const return head == NULL; void push_back(const T& elem); iterator begin(); iterator end(); ; mylist_node<t> *head, *tail; Notice the new typedef for iterator there s a big difference. begin and end now return an instance of this mylist_iterator<t> thing a type we ll more fully flesh out in a page or two.
6 While the details of how the mylist_iterator aren t clear yet, we do know that the code snippet we wrote earlier will now be translated/interpreted as follows: 6 mylist<string> ivies; ivies.push_back("harvard"); ivies.push_back("yale"); ivies.push_back("princeton"); ivies.push_back("penn"); what we write mylist<string>::iterator begin = ivies.begin(); mylist<string>::iterator end = ivies.end(); while (begin!= end) if (*begin == "Stanford") cout << "Stanford s an Ivy." << endl; return; ++begin; cout << "They re all snobs anyway." << endl; how the compiler interprets it when mylist<string>::iterator is a direct class instance. mylist<string> ivies; ivies.push_back("harvard"); ivies.push_back("yale"); ivies.push_back("princeton"); ivies.push_back("penn"); mylist<string>::iterator begin = ivies.begin(); mylist<string>::iterator end = ivies.end(); while ( begin.operator!=(end) ) if ( begin.operator*() == "Stanford") cout << "Stanford s an Ivy." << endl; return; begin.operator++() ; cout << "They re all snobs anyway." << endl; The placement of the new and improved mylist<string>::iterator in this context forces it to respond to operator!=, operator*, and operator++ in order to make the compiler happy. And because we want the iterator to traverse the mylist<string> and identify references to all of the strings inside, the implementations of operator!=, operator*, and operator++ need to mimic whatever functionality comes when these operators are applied to real pointers. Naturally, we also want the begin iterator to point to the first element of the list, the next iterator to somehow associate with the second element in the list, and so on.
7 7 Therefore, we need the following: class mylist_iterator : public iterator<forward_iterator_tag, T> friend class mylist<t>; T& operator*(); const mylist_iterator<t>& operator++(); bool operator!=(const mylist_iterator<t>& other) const; ; mylist_node<t> *pointee; mylist_iterator(mylist_node<t> *pointee) : pointee(pointee) T& mylist_iterator<t>::operator*() return pointee->elem; const mylist_iterator<t>& mylist_iterator<t>::operator++() assert(pointee!= NULL); pointee = pointee->next; return *this; bool mylist_iterator<t>:: operator!=(const mylist_iterator<t>& other) const return this->pointee!= other.pointee; Forget about public versus private for the moment; pay attention to what this mylist_iterator<t> class encapsulates and how it behaves like a pointer to an object of type T. Each instance of this mylist_iterator<t> class wraps around a pointer to a mylist_node<t>. operator++ doesn t advance the iterator to point to the next node in sequential memory, but instead to point to the next node in the list (note the update setting pointer to pointer->next). operator!= mismatches mylist_iterators if and only if the mylist_node<t> *s they surround are different. operator* returns a reference to the T object embedded inside the node whose address it s storing. You ll should make note of my decision to make all three operator methods public; marking them as private would prevent client code from handling iterators produced by the begin and end methods. See the private constructor? That means no one except the mylist<t> class can create mylist_iterator<t> s around a mylist_node<t> *. (The copy constructor, operator= method, and destructor are all public and compiler-synthesized, and the compiler-synthesized ones work just fine.)
8 8 The implementation of operator++ is such that the following idiom would carry the iterator over all of the mylist_node<t> *s of a mylist<t>. begin would need to create an iterator storing the very first address, and then operator++ would update the iterator to hold the next field, and then the next next field, and then the NEXT next field, and so on. Eventually, the iterator would be updated to store a NULL and match the iterator produced by the end method: That would be the signal that we ve reached the end of the list. Assuming this is all true, it makes the implementation of begin and end pretty obvious: class mylist typedef mylist_iterator<t> iterator; mylist() : head(null), tail(null) ~mylist() delete head; bool empty() const return head == NULL; void push_back(const T& elem); iterator begin() return mylist_iterator<t>(head); iterator end() return mylist_iterator<t>(null); ; mylist_node<t> *head, *tail; The Full mylist<t> Definition If you inspect the assn-7-ss-and-btmap starter folder, you ll see a subfolder name list-iterator-code. Within that directory is an even more robust definition and implementation of mylist. This mylist defines two find methods (one const, one non-const) and how you can use a static template method to unify their implementations implementations while are logically identical. It also shows you how to define the mylist_iterator template class so that both iterator and const_iterator can be supported. (Note that you are not required to implement true iterators for the btree_map. But you re certainly welcome and even encouraged to try.)
CS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator=
CS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator= Much of the surrounding prose written by Andy Maag, CS193D instructor from years ago. The compiler will supply a default (zero-argument)
More informationCS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator=
CS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator= We already know that the compiler will supply a default (zero-argument) constructor if the programmer does not specify one.
More informationCS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team
CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A
More informationC++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
More informationObject Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
More informationN3458: Simple Database Integration in C++11
N3458: Simple Database Integration in C++11 Thomas Neumann Technische Univeristät München neumann@in.tum.de 2012-10-22 Many applications make use of relational database to store and query their data. However,
More informationLet s start with a simple, object-oriented model of a point in two-dimensional space:
CS107L Handout 01 Autumn 2007 September 28, 2007 Constructors and Destructors point class Let s start with a simple, object-oriented model of a point in two-dimensional space: class point public: point(double
More informationC++ Overloading, Constructors, Assignment operator
C++ Overloading, Constructors, Assignment operator 1 Overloading Before looking at the initialization of objects in C++ with constructors, we need to understand what function overloading is In C, two functions
More informationIntegrating the C++ Standard Template Library Into the Undergraduate Computer Science Curriculum
Integrating the C++ Standard Template Library Into the Undergraduate Computer Science Curriculum James P. Kelsh James.Kelsh@cmich.edu Roger Y. Lee lee@cps.cmich.edu Department of Computer Science Central
More informationComp151. Definitions & Declarations
Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const
More informationLecture Notes on Binary Search Trees
Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 17 October 23, 2014 1 Introduction In this lecture, we will continue considering associative
More informationA binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:
Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)
More informationFor the next three questions, consider the class declaration: Member function implementations put inline to save space.
Instructions: This homework assignment focuses on basic facts regarding classes in C++. Submit your answers via the Curator System as OQ4. For the next three questions, consider the class declaration:
More informationBoolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
More informationC++FA 3.1 OPTIMIZING C++
C++FA 3.1 OPTIMIZING C++ Ben Van Vliet Measuring Performance Performance can be measured and judged in different ways execution time, memory usage, error count, ease of use and trade offs usually have
More informationLecture 12 Doubly Linked Lists (with Recursion)
Lecture 12 Doubly Linked Lists (with Recursion) In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively)
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College November 25, 2015 Outline Outline 1 Chapter 12: C++ Templates Outline Chapter 12: C++ Templates 1 Chapter 12: C++ Templates
More informationData Structures Using C++ 2E. Chapter 5 Linked Lists
Data Structures Using C++ 2E Chapter 5 Linked Lists Test #1 Next Thursday During Class Cover through (near?) end of Chapter 5 Objectives Learn about linked lists Become aware of the basic properties of
More information1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++
Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The
More informationFriendship and Encapsulation in C++
Friendship and Encapsulation in C++ Adrian P Robson Department of Computing University of Northumbria at Newcastle 23rd October 1995 Abstract There is much confusion and debate about friendship and encapsulation
More informationIntroduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1
Introduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1 Introduction to Classes Classes as user-defined types We have seen that C++ provides a fairly large set of built-in types. e.g
More informationWhy you shouldn't use set (and what you should use instead) Matt Austern
Why you shouldn't use set (and what you should use instead) Matt Austern Everything in the standard C++ library is there for a reason, but it isn't always obvious what that reason is. The standard isn't
More informationLinked Lists: Implementation Sequences in the C++ STL
Linked Lists: Implementation Sequences in the C++ STL continued CS 311 Data Structures and Algorithms Lecture Slides Wednesday, April 1, 2009 Glenn G. Chappell Department of Computer Science University
More informationNode-Based Structures Linked Lists: Implementation
Linked Lists: Implementation CS 311 Data Structures and Algorithms Lecture Slides Monday, March 30, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org
More informationLecture Notes on Binary Search Trees
Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning Lecture 17 March 17, 2010 1 Introduction In the previous two lectures we have seen how to exploit the structure
More information1 Abstract Data Types Information Hiding
1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content
More informationCommon Data Structures
Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees
More informationLecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists
Lecture 11 Doubly Linked Lists & Array of Linked Lists In this lecture Doubly linked lists Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for a Sparse
More informationFirst programming project: Key-Word indexer
University of Illinois at Chicago CS 202: Data Structures and Discrete Mathematics II Handout 2 Professor Robert H. Sloan Friday, August 30, 2002 First programming project: Key-Word indexer 1 Indexing
More informationCompile-time type versus run-time type. Consider the parameter to this function:
CS107L Handout 07 Autumn 2007 November 16, 2007 Advanced Inheritance and Virtual Methods Employee.h class Employee public: Employee(const string& name, double attitude, double wage); virtual ~Employee();
More informationIS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
More informationC++ Programming Language
C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract
More informationGDB Tutorial. A Walkthrough with Examples. CMSC 212 - Spring 2009. Last modified March 22, 2009. GDB Tutorial
A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
More information10CS35: Data Structures Using C
CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a
More informationData Structures Using C++ 2E. Chapter 5 Linked Lists
Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given
More informationMath 4310 Handout - Quotient Vector Spaces
Math 4310 Handout - Quotient Vector Spaces Dan Collins The textbook defines a subspace of a vector space in Chapter 4, but it avoids ever discussing the notion of a quotient space. This is understandable
More informationSequences in the C++ STL
CS 311 Data Structures and Algorithms Lecture Slides Wednesday, November 4, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn
More informationADTs,, Arrays, Linked Lists
1 ADTs,, Arrays, Linked Lists Outline and Required Reading: ADTs ( 2.1.2) Arrays ( 1.5) Linked Lists ( 4.3.1, 4.3.2) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic Abstract Data Type (ADT) 2 abstract
More informationNTFS permissions represent a core part of Windows s security system. Using
bonus appendix NTFS Permissions NTFS permissions represent a core part of Windows s security system. Using this feature, you can specify exactly which coworkers are allowed to open which files and folders
More informationCopyright 2001, Bill Trudell. Permission is granted to copy for the PLoP 2001 conference. All other rights reserved.
The Secret Partner Pattern Revision 3a by Bill Trudell, July 23, 2001 Submitted to the Pattern Languages of Programs Shepherd: Neil Harrison PC Member: Kyle Brown Thumbnail This paper describes the Secret
More information1. Polymorphism in C++...2
1. Polymorphism in C++...2 1.1 Polymorphism and virtual functions... 2 1.2 Function call binding... 3 1.3 Virtual functions... 4 1.4 How C++ implements late binding... 6 1.4.1 Why do I have to know at
More informationLinked List as an ADT (cont d.)
Linked List as an ADT (cont d.) Default constructor Initializes list to an empty state Destroy the list Deallocates memory occupied by each node Initialize the list Reinitializes list to an empty state
More informationHow to create PDF maps, pdf layer maps and pdf maps with attributes using ArcGIS. Lynne W Fielding, GISP Town of Westwood
How to create PDF maps, pdf layer maps and pdf maps with attributes using ArcGIS Lynne W Fielding, GISP Town of Westwood PDF maps are a very handy way to share your information with the public as well
More informationC++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
More informationCours de C++ Utilisations des conteneurs
Cours de C++ Utilisations des conteneurs Cécile Braunstein cecile.braunstein@lip6.fr 1 / 18 Introduction Containers - Why? Help to solve messy problems Provide useful function and data structure Consistency
More informationC++ Crash Kurs. C++ Object-Oriented Programming
C++ Crash Kurs C++ Object-Oriented Programming Dr. Dennis Pfisterer Institut für Telematik, Universität zu Lübeck http://www.itm.uni-luebeck.de/people/pfisterer C++ classes A class is user-defined type
More information16 Collection Classes
16 Collection Classes Collections are a key feature of the ROOT system. Many, if not most, of the applications you write will use collections. If you have used parameterized C++ collections or polymorphic
More informationPART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
More informationDecision Making under Uncertainty
6.825 Techniques in Artificial Intelligence Decision Making under Uncertainty How to make one decision in the face of uncertainty Lecture 19 1 In the next two lectures, we ll look at the question of how
More informationWhere's Gone? LEAD GENERATION PRINTABLE WORKBOOK
Have you ever stopped to think why you are in business? Good question, isn t it? But before we take a closer look at this, spend a few moments now thinking about what you believe your reasons to be. Jot
More informationShort Notes on Dynamic Memory Allocation, Pointer and Data Structure
Short Notes on Dynamic Memory Allocation, Pointer and Data Structure 1 Dynamic Memory Allocation in C/C++ Motivation /* a[100] vs. *b or *c */ Func(int array_size) double k, a[100], *b, *c; b = (double
More informationChapter 3: Restricted Structures Page 1
Chapter 3: Restricted Structures Page 1 1 2 3 4 5 6 7 8 9 10 Restricted Structures Chapter 3 Overview Of Restricted Structures The two most commonly used restricted structures are Stack and Queue Both
More informationWriting Thesis Defense Papers
Writing Thesis Defense Papers The point of these papers is for you to explain and defend a thesis of your own critically analyzing the reasoning offered in support of a claim made by one of the philosophers
More information0.8 Rational Expressions and Equations
96 Prerequisites 0.8 Rational Expressions and Equations We now turn our attention to rational expressions - that is, algebraic fractions - and equations which contain them. The reader is encouraged to
More informationRUP iteration planning
Page 1 of 13 Copyright IBM Corporation 2004. http://www-106.ibm.com/developerworks/rational/library/5335.html Search for: within All of dw Use + - ( ) " " Search help IBM home Products & services Support
More informationVariable Base Interface
Chapter 6 Variable Base Interface 6.1 Introduction Finite element codes has been changed a lot during the evolution of the Finite Element Method, In its early times, finite element applications were developed
More informationName: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
More informationCreating and Managing Shared Folders
Creating and Managing Shared Folders Microsoft threw all sorts of new services, features, and functions into Windows 2000 Server, but at the heart of it all was still the requirement to be a good file
More informationSoftware Engineering Concepts: Testing. Pointers & Dynamic Allocation. CS 311 Data Structures and Algorithms Lecture Slides Monday, September 14, 2009
Software Engineering Concepts: Testing Simple Class Example continued Pointers & Dynamic Allocation CS 311 Data Structures and Algorithms Lecture Slides Monday, September 14, 2009 Glenn G. Chappell Department
More informationCpt S 223. School of EECS, WSU
Abstract Data Types 1 Topics Abstract Data Types (ADTs) Some basic ADTs: Lists Stacks Queues 2 Primitive Data Type vs. Abstract Data Types Primitive DT: ADT: programmer progra ammer Interface (API) e.g.,
More informationCpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing
CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects
More informationSymbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
More informationWhat you should know about: Windows 7. What s changed? Why does it matter to me? Do I have to upgrade? Tim Wakeling
What you should know about: Windows 7 What s changed? Why does it matter to me? Do I have to upgrade? Tim Wakeling Contents What s all the fuss about?...1 Different Editions...2 Features...4 Should you
More informationOperator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example
Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics
More informationCoding Rules. Encoding the type of a function into the name (so-called Hungarian notation) is forbidden - it only confuses the programmer.
Coding Rules Section A: Linux kernel style based coding for C programs Coding style for C is based on Linux Kernel coding style. The following excerpts in this section are mostly taken as is from articles
More informationObject Oriented Software Design II
Object Oriented Software Design II Real Application Design Christian Nastasi http://retis.sssup.it/~lipari http://retis.sssup.it/~chris/cpp Scuola Superiore Sant Anna Pisa April 25, 2012 C. Nastasi (Scuola
More informationLab 4.4 Secret Messages: Indexing, Arrays, and Iteration
Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration This JavaScript lab (the last of the series) focuses on indexing, arrays, and iteration, but it also provides another context for practicing with
More informationSyntax Check of Embedded SQL in C++ with Proto
Proceedings of the 8 th International Conference on Applied Informatics Eger, Hungary, January 27 30, 2010. Vol. 2. pp. 383 390. Syntax Check of Embedded SQL in C++ with Proto Zalán Szűgyi, Zoltán Porkoláb
More informationvector vec double # in # cl in ude <s ude tdexcept> tdexcept> // std::ou std t_of ::ou _range t_of class class V Vector { ector {
Software Design (C++) 3. Resource management and exception safety (idioms and technicalities) Juha Vihavainen University of Helsinki Preview More on error handling and exceptions checking array indices
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More informationBasics of C++ and object orientation in OpenFOAM
Basics of C++ and object orientation in OpenFOAM To begin with: The aim of this part of the course is not to teach all of C++, but to give a short introduction that is useful when trying to understand
More informationDebugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
More informationLecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c
Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection
More informationNot agree with bug 3, precision actually was. 8,5 not set in the code. Not agree with bug 3, precision actually was
Task 1 Task 2 Task 3 Feedback Presence SUM Matrikkel Rühm [5] [1] [2] [1] [1] [10] Feedback to students A64129 1. rühm 0 0 No submission found A72068 1. rühm 5 1 2 1 1 For Bug 3. Actually the variable
More informationCORBA Programming with TAOX11. The C++11 CORBA Implementation
CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy
More informationIt starts like this...
Need help with your phone? No problem. Just get in touch with the store or website you bought it from. If you need a hand with your mobile service, one of our team will be happy to help. 789 on your mobile
More informationPre-Algebra Lecture 6
Pre-Algebra Lecture 6 Today we will discuss Decimals and Percentages. Outline: 1. Decimals 2. Ordering Decimals 3. Rounding Decimals 4. Adding and subtracting Decimals 5. Multiplying and Dividing Decimals
More informationBBC Learning English Talk about English Business Language To Go Part 1 - Interviews
BBC Learning English Business Language To Go Part 1 - Interviews This programme was first broadcast in 2001. This is not a word for word transcript of the programme This series is all about chunks of language
More informationMcKinsey Problem Solving Test Top Tips
McKinsey Problem Solving Test Top Tips 1 McKinsey Problem Solving Test You re probably reading this because you ve been invited to take the McKinsey Problem Solving Test. Don t stress out as part of the
More informationCmpSci 187: Programming with Data Structures Spring 2015
CmpSci 187: Programming with Data Structures Spring 2015 Lecture #12 John Ridgway March 10, 2015 1 Implementations of Queues 1.1 Linked Queues A Linked Queue Implementing a queue with a linked list is
More informationEverything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6
Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Number Systems No course on programming would be complete without a discussion of the Hexadecimal (Hex) number
More informationEmail Marketing Now let s get started on probably the most important part probably it is the most important part of this system and that s building your e-mail list. The money is in the list, the money
More informationSocial Return on Investment
Social Return on Investment Valuing what you do Guidance on understanding and completing the Social Return on Investment toolkit for your organisation 60838 SROI v2.indd 1 07/03/2013 16:50 60838 SROI v2.indd
More informationrecursion, O(n), linked lists 6/14
recursion, O(n), linked lists 6/14 recursion reducing the amount of data to process and processing a smaller amount of data example: process one item in a list, recursively process the rest of the list
More informationSlave Computer 1 Slave Computer 2
MotoTally Networking Guide Windows XP Introduction This networking guide will show you how to configure your computers on a network so you can run multiple instances of MotoTally on multiple computers,
More informationWRITING PROOFS. Christopher Heil Georgia Institute of Technology
WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this
More informationOrdered Lists and Binary Trees
Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 6-0:
More informationThe Doctor-Patient Relationship
The Doctor-Patient Relationship It s important to feel at ease with your doctor. How well you are able to talk with your doctor is a key part of getting the care that s best for you. It s also important
More information50 Tough Interview Questions
You and Your Accomplishments 1. Tell me a little about yourself. 50 Tough Interview Questions Because this is often the opening question, be careful that you don t run off at the mouth. Keep your answer
More informationGetting Started with WebSite Tonight
Getting Started with WebSite Tonight WebSite Tonight Getting Started Guide Version 3.0 (12.2010) Copyright 2010. All rights reserved. Distribution of this work or derivative of this work is prohibited
More informationCS11 Advanced C++ Spring 2008-2009 Lecture 9 (!!!)
CS11 Advanced C++ Spring 2008-2009 Lecture 9 (!!!) The static Keyword C++ provides the static keyword Also in C, with slightly different usage Used in two main contexts: Declaring static members of a class
More informationStacks. Linear data structures
Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations
More informationThe Top 3 Common Mistakes Men Make That Blow All Their Chances of Getting Their Ex-Girlfriend Back Which of these mistakes are you making?
The Top 3 Common Mistakes Men Make That Blow All Their Chances of Getting Their Ex-Girlfriend Back Which of these mistakes are you making? By George Karanastasis, M.D. COPYRIGHT NOTICE THIS ELECTRONIC
More informationThe Little Go Book is licensed under the Attribution-NonCommercial-ShareAlike 4.0 International license. You should not have paid for this book.
1 The Little Go Book is licensed under the Attribution-NonCommercial-ShareAlike 4.0 International license. You should not have paid for this book. You are free to copy, distribute, modify or display the
More informationCurriculum Map. Discipline: Computer Science Course: C++
Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code
More informationKITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
More informationMATLAB Functions. function [Out_1,Out_2,,Out_N] = function_name(in_1,in_2,,in_m)
MATLAB Functions What is a MATLAB function? A MATLAB function is a MATLAB program that performs a sequence of operations specified in a text file (called an m-file because it must be saved with a file
More informationFIELD GUIDE TO LEAN EXPERIMENTS
FIELD GUIDE TO LEAN EXPERIMENTS LEAN ENTERPRISE ACCELERATOR PROGRAM HOW TO USE THIS GUIDE This guide is designed to be used in conjunction with the Experiment Map posters. If you have not done so already,
More informationUnordered Linked Lists
Unordered Linked Lists Derive class unorderedlinkedlist from the abstract class linkedlisttype Implement the operations search, insertfirst, insertlast, deletenode See code on page 292 Defines an unordered
More information