Arrays and Collections

Slides:



Advertisements
Similar presentations
Chapter 24 Lists, Stacks, and Queues
Advertisements

David Weinberg presents Linked Lists: The Background  Linked Lists are similar to ArrayLists in their appearance and method of manipulation  They do.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
Arrays. A group of data with same type stored under one variable. It is assumed that elements in that group are ordered in series. In C# language arrays.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
COP INTERMEDIATE JAVA Data Structures. A data structure is a way of organizing a collection of data so that it can be manipulated effectively. A.
C Programming – Part 3 Arrays and Strings.  Collection of variables of the same type  Individual array elements are identified by an integer index 
List Interface and Linked List Mrs. Furman March 25, 2010.
Generics & Collection Classes Version 1.0. Topics Generic Methods and Classes Generic Collection Classes List Enumerators Queue Stack LinkedList.
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
1 dimensional static Array Int[] a = new int[4]; A[0]A[1]A[2]A[3] Int[] b= new int[1]; B[0] Array is a list of variables having same name and same data.
Quick Summary C++/CLI Basics Data Types Controls Arrays In-class assignments.
Chapter  Array-like data structures  ArrayList  Queue  Stack  Hashtable  SortedList  Offer programming convenience for specific access.
1 Data Organization Example 1: Heap storage management Maintain a sequence of free chunks of memory Find an appropriate chunk when allocation is requested.
1 Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues Jung Soo (Sue) Lim Cal State LA.
Data Types Chapter 6: Data Types Lectures # 11. Topics Introduction Primitive Data Types Character String Types Array Types Associative Arrays Record.
Lecture 10 Collections Richard Gesick.
Arrays Chapter 7.
Data Structure By Amee Trivedi.
Chapter 6 – Data Types CSCE 343.
4. Linked Lists.
Ch7. List and Iterator ADTs
UNIT – I Linked Lists.
IS 350 Arrays.
© 2016 Pearson Education, Ltd. All rights reserved.
MIS 215 Module 1 – Unordered Lists
Data Structure and Algorithms
John Hurley Cal State LA
Fundamentals of Java: AP Computer Science Essentials, 4th Edition
Sequences and Iterators
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Data Structures and Database Applications Linked Lists
Prof. Neary Adapted from slides by Dr. Katherine Gibson
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
CS313D: Advanced Programming Language
Linked Lists.
Object Oriented Programming COP3330 / CGS5409
Arrays and Linked Lists
Lecture 10 List Richard Gesick.
Chapter : Arrays.
Linked List Intro CSCE 121 J. Michael Moore.
MON TUE WED THU
Introduction to Data Structures
List Implementations Chapter 9.
Introduction To Programming Information Technology , 1’st Semester
CS2013 Lecture 4 John Hurley Cal State LA.
Can store many of the same kind of data together
Object Oriented Programming in java
JavaScript Arrays.
Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues
MSIS 655 Advanced Business Applications Programming
Arrays Chapter 7.
Linked List and Selection Sort
2008 Calendar.
Collections Framework
Sun Mon Tue Wed Thu Fri Sat
The Generic LinkedList<> Collection class
JavaScript: Arrays.
Fundaments of Game Design
Sun Mon Tue Wed Thu Fri Sat
1/○~1/○ weekly schedule MON TUE WED THU FRI SAT SUN MEMO
2016 | 10 OCT SUN MON TUE WED THU FRI SAT
Linked List Intro CSCE 121.
Sun Mon Tue Wed Thu Fri Sat
Ps Module 7 – Part II 2D Arrays and LISTS 5/26/2019 CSE 1321 Module 7.
Arrays and ArrayLists.
Arrays.
2008 Calendar.
Presentation transcript:

Arrays and Collections One dimensional array Two or multiple dimensional array Collections Standard collection: ArrayList Generic collection: LinkedList The individual values of an array are boxed if they are value types. Array indices are zero based. The array type has methods for accessing and manipulating the contents of the array. All operations on the array are bound checked. Any access beyond the maximum size of the array results in an exception - "Index out of range". Arrays get allocated only on the heap; hence an array of value types gets all its values boxed to the heap.

Array in C++/CLI Array, element, index(or subscript) array<int> ^ a = gcnew array<int>(12); array<int> ^ a = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; a[0], a[1],…, and a[11] a->Length array<String ^> ^d = {“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”}; int main(array<System::String ^> ^args) {}

Array in C++/CLI Multi-dimensional Array array<int, 2> ^ b = gcnew array<int, 2>(4,3); array<int, 2> ^ b = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {0, 1, 2}}; b[0,0], b[0,1],…, b[3,2]; b->Rank, b->GetLength(0), b->GetLength(1) Parentheses Square bracket Angle bracket Curly Brace

Collections in C++/CLI ArrayList (System::Collections Namespace) Index-based Constant-time random access consecutive Dynamically growing arrays, re-sizeable LinkedList (System::Collections::Generic Namespace) Traverse the list to find the proper node Dis-contiguous An array list is a collection of one or more (usually more) elements arranged in memory in a consecutive fashion, accessed as one indexable entity. A linked list is a collection of one or more (usually more) elements arranged in memory in a (usually) dis-contiguous fashion, using pointers contained in each element that point to the next element in the list. 

Collections in C++/CLI ArrayList ^ list1 = gcnew ArrayList(); Property: Count Methods: [], Add, AddRange, Insert, InsertRange, Remove, RemoveAt, RemoveRange, Clear, Reverse, Sort, Contains, IndexOf

Collections in C++/CLI LinkedList<String^> ^list2 = gcnew LinkedList<String^>(); LinkedListNode<String^> ^cur; cur->Value, cur->Next; cur->Previous (nullptr) Property: Count, First, Last Methods: AddFirst, AddLast, AddBefore, AddAfter, RemoveFirst, RemoveLast, Remove, Clear, Find,

Example: testArrayCollection.cpp Single and two dimensional arrays Type of string reference, fixed length