Session 07 Module 13 - Collections. Collections / Session 7 / 2 of 32 Review  A delegate in C# is used to refer to a method in a safe manner.  To invoke.

Slides:



Advertisements
Similar presentations
11 Copyright © 2005, Oracle. All rights reserved. Using Arrays and Collections.
Advertisements

Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
COMP 121 Week 9: AbstractList and ArrayList. Objectives List common operations and properties of Lists as distinct from Collections Extend the AbstractCollection.
Generics, Lists, Interfaces
Collections Chapter Java Collection Frameworks The Java collection framework is a set of utility classes and interfaces. Designed for working with.
Data Structures and Collections
1 Generic Collections Chapter Objectives You will be able to Use generic collection classes available in the.NET framework.
C# Data Structures AND Generics By Michael and Miles.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L11 (Chapter 20) Lists, Stacks,
VBA Modules, Functions, Variables, and Constants
Slides prepared by Rose Williams, Binghamton University Chapter 14 Generics and the ArrayList Class.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L15 (Chapter 22) Java Collections.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 10 *Arrays with more than one dimension *Java Collections API.
1 Pertemuan 6 The structure part of object data model (Lanjutan) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
C# Programming: From Problem Analysis to Program Design1 Advanced Collections C# Programming: From Problem Analysis to Program Design 3 rd Edition 8.
Chapter 7: Working with Arrays
Factory Design Pattern, cont’d COMP 401 Fall 2014 Lecture 13 10/2/2014.
Chapter 10 2D Arrays Collection Classes. Topics Arrays with more than one dimension Java Collections API ArrayList Map.
Chapter 19 Java Data Structures
Java Collections Framework A presentation by Eric Fabricant.
Classes and objects Practice 2. Basic terms  Classifier is an element of the model, which specifies some general features for a set of objects. Features.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Generics Collections. Why do we need Generics? Another method of software re-use. When we implement an algorithm, we want to re-use it for different types.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Chapter 18 Java Collections Framework
Murach’s Visual Basic 2008, modified, C8© 2008, Mike Murach & Associates, Inc. Slide 1.
1 Chapter 17 Object-Oriented Data Structures. 2 Objectives F To describe what a data structure is (§17.1). F To explain the limitations of arrays (§17.1).
Generics Collections. Why do we need Generics? Another method of software re-use. When we implement an algorithm, we want to re-use it for different types.
Understanding Data Types and Collections Lesson 2.
Exceptions, cont’d. Factory Design Pattern COMP 401 Fall 2014 Lecture 12 9/30/2014.
Session 04 Module 8: Abstract classes and Interface Module 9: Properties and Indexers.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.
Michael Olivero Microsoft Student Ambassador for FIU
Interface: (e.g. IDictionary) Specification class Appl{ ---- IDictionary dic; dic= new XXX(); application class: Dictionary SortedDictionary ----
PROGRAMMING IN C#. Collection Classes (C# Programming Guide) The.NET Framework provides specialized classes for data storage and retrieval. These classes.
Introduction to Object-Oriented Programming Lesson 2.
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
Session 1 Module 1: Introduction to Data Integrity
More Java: Static and Final, Abstract Class and Interface, Exceptions, Collections Framework 1 CS300.
Data Structures and Collections Principles.NET: –Two libraries: System.Collections System.Collections.Generics FEN 2014UCN Teknologi/act2learn1 Deprecated.
STL: Maps Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
Maps Nick Mouriski.
Slides prepared by Rose Williams, Binghamton University Chapter 16 Collections and Iterators.
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
Collections Dwight Deugo Nesa Matic
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
Chapter  Array-like data structures  ArrayList  Queue  Stack  Hashtable  SortedList  Offer programming convenience for specific access.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
Module 5: Programming with C#. Overview Using Arrays Using Collections Using Interfaces Using Exception Handling Using Delegates and Events.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Lecture 10 Collections Richard Gesick.
Chapter 7: Working with Arrays
University of Central Florida COP 3330 Object Oriented Programming
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.
Chapter 17 Object-Oriented Data Structures
CS313D: Advanced Programming Language
14.1 The java.util Package.
Object Oriented Programming in java
L5. Necessary Java Programming Techniques
5. 3 Coding with Denotations
Hashing in java.util
Presentation transcript:

Session 07 Module 13 - Collections

Collections / Session 7 / 2 of 32 Review  A delegate in C# is used to refer to a method in a safe manner.  To invoke the mothod that is referred to by the delegate, an instance of the delegate is created.  A Event is a data member that enables an object to provide notifications to other objects about a particular action.  For using an event, you must first declare a delegate and an event, define an event handler to handle the event and finally associate the handler to the event.

Collections / Session 7 / 3 of 32 Module 13 – Objectives (1)  List and explain the commonly used classes and interfaces in the System.Collections namespace  List and explain the commonly used classes and interface in the System.Collection.Generic namespace  Describle the commonly used methods and properties of ArrayList class

Collections / Session 7 / 4 of 32 Module 13 – Objectives (2)  Describe the commonly used methods and properties of Hashtable class  Describe the commonly used methods and properties of SortedList class  Describe the commonly used methods and properties of Dictionary class

Collections / Session 7 / 5 of 32 What is Collection?  A collection is a set of related data that may not necessary belong to the same data type.  Element in collection can be set or modified at run time

Collections / Session 7 / 6 of 32 System.Collections namespace  System.Collections namespace in C# allow to construct and manipulate a collection of objects.  This collection can include elements of difference data types.

Collections / Session 7 / 7 of 32 Classes

Collections / Session 7 / 8 of 32 Interface

Collections / Session 7 / 9 of 32 System.Collections.Generic namespace  Generic allow you to define data structures that consist of functionalities which can be implemented for any data type.  Generic allow you to reuse a code for different data types.  System.Collections.Generic namespace is similar to the System.Collections namespace as both allow you to create collections. However, generic collection are type safe

Collections / Session 7 / 10 of 32 System.Collections.Generic class

Collections / Session 7 / 11 of 32 System.Collections.Generic Interface

Collections / Session 7 / 12 of 32 ArrayList class  ArrayList class is a variable-length array that can dynamically increase or decrease in size.  Unlike Array class, this class can store elements of different data type.  The default capacity of an ArrayList is 16, if the number of elements in list reached the specified capacity, the capacity of list is doubled automatically.  It can accept null value and can also include duplicate elements

Collections / Session 7 / 13 of 32 Methods

Collections / Session 7 / 14 of 32 Properties

Collections / Session 7 / 15 of 32 Hash table class  Hashtable class allow you to create collections in the form of keys and values.  It generates a hash table which associated keys with their corresponding values.

Collections / Session 7 / 16 of 32 Methods

Collections / Session 7 / 17 of 32 Property

Collections / Session 7 / 18 of 32 SortedList class  SortedList class presents a collections of pair value and Key  By default SortedList sorts the elements in ascending order.  These elements either accessed using the corresponding keys or index number

Collections / Session 7 / 19 of 32 Hashtable vs. SortedList  SortedList class is a combination of the Hashtable class and the ArrayList class.  The difference between the Hashtable class and the SortedList class is that the values in object of SortedList class are sorted by their keys as well as by their index position.  However, the execution of the program using the SortedList class is slower than the programming using the Hashtable class due to sorting process.

Collections / Session 7 / 20 of 32 Hashtable vs. SortedList

Collections / Session 7 / 21 of 32 Methods

Collections / Session 7 / 22 of 32 Property

Collections / Session 7 / 23 of 32 Dictionary generic class  It consists of a generic collection of elements organized in key and value pairs.  It maps the keys to their corresponding values.  Unlike other collections in the System.Collections namespace, it is used to create a collection of a single data type at a time  The Dictionary class does not allow null value as elements.

Collections / Session 7 / 24 of 32 Methods

Collections / Session 7 / 25 of 32 Properties

Collections / Session 7 / 26 of 32 Dictionary Generic class  System.Collection.Generic namespace contains commonly used class is Dictionary generic class.  Dictionary generic class consists of a generic collection of elements organized in key and value pair.

Collections / Session 7 / 27 of 32 Dictionary generic class  Unlike other collection in the System.Collections namespace, it is used to create a collection of a single data type at a time.  Dictionary does not allow null value as elements.  Dictionary

Collections / Session 7 / 28 of 32 Method

Collections / Session 7 / 29 of 32 Property

Collections / Session 7 / 30 of 32 Session 13 – Summary (1)  Collection allow you to manage a group of objects dynamically at run-time.  The System.Collections namespace contains different collections such as arrays, hash table, list and dictionary.  System.Collection.Generic consists of generic collections that allow resuability of code and provide better type safety.

Collections / Session 7 / 31 of 32 Session 13 – Summary (2)  ArrayList class allow to increase and decrease the size of the collection during program execution.  It allow you to store elements of different data types.  Hashtable class stores elements as key and value pair where the data is organized based on the hash code.  Each value in the hash table is uniquely identified by its key

Collections / Session 7 / 32 of 32 Session 13 – Summary (3)  SortedList class allow you to store elements as key and value pairs where the data is sorted based on the key.  It allow you to access elements from the collection using the key or the index number.  Dictionary generic class represents a collection of elements organized in key and value pairs.  The key value is used to retrieve value from the collection