Collections, Part 2 You were introduced to Generic collections for assignment 3—ThingsToDraw was a Generic.List of Idrawable objects. Since the Generic.List.

Slides:



Advertisements
Similar presentations
Chapter 10 Pointers and Dynamic Arrays. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Pointers Pointer variables.
Advertisements

Array-Based Lists List Length of a list
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
Copyright 2010 by Pearson Education Building Java Programs Chapter 7 Lecture 7-2: Arrays as Parameters reading: , 3.3 self-checks: Ch. 7 #5, 8,
Object Oriented Programming COP3330 / CGS5409.  C++ Automatics ◦ Copy constructor () ◦ Assignment operator =  Shallow copy vs. Deep copy  DMA Review.
CS102--Object Oriented Programming Lecture 17: – Linked Lists Copyright © 2008 Xiaoyan Li.
Topic 9 – Introduction To Arrays. CISC105 – Topic 9 Introduction to Data Structures Thus far, we have seen “simple” data types. These refers to a single.
1 CS 201 Compiler Construction Lecture 12 Global Register Allocation.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
©2004 Brooks/Cole Chapter 10 More on Classes. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Object assignment With primitive types, setting.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
1 Using Classes Object-Oriented Programming Using C++ Second Edition 5.
Using Classes Object-Oriented Programming Using C++ Second Edition 5.
Data Objects (revisited) Recall that values are stored in data objects, and that each data object holds one value of a particular type. Data objects may.
Copyright © 2001 by Wiley. All rights reserved. Chapter 12: Programmer- Defined Types, Direct Access Files, and Object Classes Programmer Defined Data.
DCT1063 Programming 2 CHAPTER 5 ADVANCED DATA TYPE (part 1) Mohd Nazri Bin Ibrahim Faculty of Computer Media and Technology TATi University College
JavaScript, Fourth Edition
Computer Architecture and the Fetch-Execute Cycle
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 26: Exam 2 Preview.
Array in C++ / review. An array contains multiple objects of identical types stored sequentially in memory. The individual objects in an array, referred.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Slides prepared by Rose Williams, Binghamton University Chapter 15 Linked Data Structures.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Classes and Multiform Projects.
Pointers. What is pointer l Everything stored in a computer program has a memory address. This is especially true of variables. char c=‘y’; int i=2; According.
Arrays Arrays in C++ An array is a data structure which allows a collective name to be given to a group of elements which all have.
1 Pointers to structs. 2 A pointer to a struct is used in the same way as a pointer to a simple type, such as an int. Pointers to structs were introduced.
Python Arrays. An array is a variable that stores a collection of things, like a list. For example a list of peoples names. We can access the different.
Lecture 04 – Models of memory Mutable and immutable data.
Computer Organization and Design Pointers, Arrays and Strings in C Montek Singh Sep 18, 2015 Lab 5 supplement.
Arrays An array is a data object that can hold multiple objects, all of the same type. We can think of an array as a storage box which has multiple compartments.
Lecture 2 Programming life cycle. computer piano analogy Piano + player - computer hardware Musical score/notes - software or program Composer - programmer.
Using Lists Games Programming in Scratch. Games Programming in Scratch Extension – Using Lists Learning Objectives Create a temporary data store (list)
Chapter 8: Advanced Method Concepts. Understanding Parameter Types Mandatory parameter – An argument for it is required in every method call Four types.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter Array Basics.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 10 More on Objects and Classes.
Collections 1. Two Hierarchies Recall that the architecture of an object- oriented program consists of two hierarchies: – The Class Structure (“is a”)
1 Arrays of Arrays Quick review … arrays Arrays of arrays ≡ multidimensional array Example: times table Representation in memory Ragged arrays Example:
CSCI 161 Lecture 14 Martin van Bommel. New Structure Recall “average.cpp” program –Read in a list of numbers –Count them and sum them up –Calculate the.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
ENEE150 – 0102 ANDREW GOFFIN More With Pointers. Importance of Pointers Dynamic Memory (relevant with malloc) Passing By Reference Pointer Arithmetic.
CSC 142 F 1 CSC 142 References and Primitives. CSC 142 F 2 Review: references and primitives  Reference: the name of an object. The type of the object.
Project 1 : Phase 1 22C:021 CS II Data Structures.
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
1 CSC103: Introduction to Computer and Programming Lecture No 17.
Data Storage So far variables have been able to store only one value at a time. What do you do if you have many similar values that all need to be stored?
Object-Oriented Programming Using C++ Third Edition Chapter 7 Using Classes.
Chapter 10: Void Functions
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
Basic notes on pointers in C
Pointers and References
Introduction to Classes
Practice Six Chapter Eight.
Return by Reference CSCE 121 J. Michael Moore.
Simulating Reference Parameters in C
Reference semantics, variables and names
Why did the programmer quit his job?
Java Programming Language
A simple function.
Pointers and References
C Parameter Passing.
Presentation transcript:

Collections, Part 2 You were introduced to Generic collections for assignment 3—ThingsToDraw was a Generic.List of Idrawable objects. Since the Generic.List is a collection of objects, it follows the object-oriented method of data storage: Like an object variable, the Generic.List contains the memory addresses of the objects, not the objects themselves. 1

Object Variables Recall this sample program from earlier, showing approximately how object data is stored and accessed by variables in VB: 2

Object Collections and Assignments This form demonstrated how object arrays work: Generic Collections work in a very similar fashion: Like the yellow box above, they are collections of addresses—not the actual objects. This means that if you have another reference (a variable name, or as a member of another collection) to one of its objects, if you modify the object using one reference, it modifies the object for all references. 3

Example Above is some simple code which: – Creates a Generic.List(Of Student) – Creates a new Student object and assigns it to the variable s (which will then contain the address of the Student object) – Adds the object to the Generic.List (which also now contains the address of the object) – Modifies the object using the variable – This causes the object stored in the Generic.List to be modified as well, because it is the same object (not a copy) 4