SlideShare a Scribd company logo
Collections and Generics
Dr.Haitham A. El-Ghareeb
Information Systems Department
Faculty of Computers and Information Sciences
Mansoura University
helghareeb@gmail.com
September 30, 2012
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 1 / 13
Good News
Received: 23 September 2012
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 2 / 13
Good News
http://www.helghareeb.me/courses/dsa-2012
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 3 / 13
Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
Collections
A collection is a structured data type that stores data and provides
operations for adding data to the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
Collections
A collection is a structured data type that stores data and provides
operations for adding data to the collection.
Operations include:
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
Collections
A collection is a structured data type that stores data and provides
operations for adding data to the collection.
Operations include:
removing data from the collection
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
Collections
A collection is a structured data type that stores data and provides
operations for adding data to the collection.
Operations include:
removing data from the collection
updating data in the collection
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
Collections
A collection is a structured data type that stores data and provides
operations for adding data to the collection.
Operations include:
removing data from the collection
updating data in the collection
and operations for setting and returning the values of different
attributes of the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
Collection Types
Collections can be broken down into two types: linear and nonlinear.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows the
previous element.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows the
previous element.
Elements in a linear collection are normally ordered by position (first,
second, third, etc.).
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows the
previous element.
Elements in a linear collection are normally ordered by position (first,
second, third, etc.).
Nonlinear collections hold elements that do not have positional order
within the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows the
previous element.
Elements in a linear collection are normally ordered by position (first,
second, third, etc.).
Nonlinear collections hold elements that do not have positional order
within the collection.
An organizational chart is an example of a non- linear collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
Collection Properties and Methods
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
Collection Properties and Methods
Collection Property is the collections Count, which holds the number
of items in the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
Collection Properties and Methods
Collection Property is the collections Count, which holds the number
of items in the collection.
Collection operations, called methods, include:
Add (for adding a new element to a collection)
Insert (for adding a new element to a collection at a specified index)
Remove (for removing a specified element from a collection)
Clear (for removing all the elements from a collection)
Contains (for determining if a specified element is a member of a
collection)
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
Linear Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
Linear Collections
Direct Access Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
Linear Collections
Direct Access Collections
Sequential Access Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
Linear Collections
Direct Access Collections
Sequential Access Collections
Generalized Indexed Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
Struct
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 8 / 13
Non Linear Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
Non Linear Collections
Hierarchical Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
Non Linear Collections
Hierarchical Collections
Group Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
My Collection Class
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 10 / 13
Generic Programming
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 11 / 13
Oversimplified Timing Tests
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 12 / 13
Charting in .Net
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 13 / 13

More Related Content

PDF
DSA-2012-Lect00
PDF
DSA - Lecture 03
PDF
Lecture 01 - Research Methods
PDF
Lecture 07 Data Structures - Basic Sorting
PDF
Lecture 9 - DSA - Python Data Structures
PPT
Stacks queues-1220971554378778-9
PDF
Sienna6bst 120411102353-phpapp02
PDF
Programmingwithc 131017034813-phpapp01
DSA-2012-Lect00
DSA - Lecture 03
Lecture 01 - Research Methods
Lecture 07 Data Structures - Basic Sorting
Lecture 9 - DSA - Python Data Structures
Stacks queues-1220971554378778-9
Sienna6bst 120411102353-phpapp02
Programmingwithc 131017034813-phpapp01

More from Getachew Ganfur (10)

PDF
Labmanualc2ndedition2 2-121115034959-phpapp02
PDF
His162013 140529214456-phpapp01
PPT
Fundamentalsofdatastructures 110501104205-phpapp02
PPTX
Ds 111011055724-phpapp01
DOCX
Document(1)
DOC
Datastructurenotes 100627004340-phpapp01
PPTX
Datastructureanditstypes 110410094332-phpapp02
PPT
Cppt 101102014428-phpapp01
PPT
Ccourse 140618093931-phpapp02
DOCX
1to5 4th
Labmanualc2ndedition2 2-121115034959-phpapp02
His162013 140529214456-phpapp01
Fundamentalsofdatastructures 110501104205-phpapp02
Ds 111011055724-phpapp01
Document(1)
Datastructurenotes 100627004340-phpapp01
Datastructureanditstypes 110410094332-phpapp02
Cppt 101102014428-phpapp01
Ccourse 140618093931-phpapp02
1to5 4th
Ad

Lect02 120929183452-phpapp02

  • 1. Collections and Generics Dr.Haitham A. El-Ghareeb Information Systems Department Faculty of Computers and Information Sciences Mansoura University helghareeb@gmail.com September 30, 2012 Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 1 / 13
  • 2. Good News Received: 23 September 2012 Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 2 / 13
  • 3. Good News http://www.helghareeb.me/courses/dsa-2012 Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 3 / 13
  • 4. Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
  • 5. Collections A collection is a structured data type that stores data and provides operations for adding data to the collection. Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
  • 6. Collections A collection is a structured data type that stores data and provides operations for adding data to the collection. Operations include: Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
  • 7. Collections A collection is a structured data type that stores data and provides operations for adding data to the collection. Operations include: removing data from the collection Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
  • 8. Collections A collection is a structured data type that stores data and provides operations for adding data to the collection. Operations include: removing data from the collection updating data in the collection Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
  • 9. Collections A collection is a structured data type that stores data and provides operations for adding data to the collection. Operations include: removing data from the collection updating data in the collection and operations for setting and returning the values of different attributes of the collection. Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
  • 10. Collection Types Collections can be broken down into two types: linear and nonlinear. Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
  • 11. Collection Types Collections can be broken down into two types: linear and nonlinear. A linear collection is a list of elements where one element follows the previous element. Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
  • 12. Collection Types Collections can be broken down into two types: linear and nonlinear. A linear collection is a list of elements where one element follows the previous element. Elements in a linear collection are normally ordered by position (first, second, third, etc.). Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
  • 13. Collection Types Collections can be broken down into two types: linear and nonlinear. A linear collection is a list of elements where one element follows the previous element. Elements in a linear collection are normally ordered by position (first, second, third, etc.). Nonlinear collections hold elements that do not have positional order within the collection. Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
  • 14. Collection Types Collections can be broken down into two types: linear and nonlinear. A linear collection is a list of elements where one element follows the previous element. Elements in a linear collection are normally ordered by position (first, second, third, etc.). Nonlinear collections hold elements that do not have positional order within the collection. An organizational chart is an example of a non- linear collection. Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
  • 15. Collection Properties and Methods Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
  • 16. Collection Properties and Methods Collection Property is the collections Count, which holds the number of items in the collection. Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
  • 17. Collection Properties and Methods Collection Property is the collections Count, which holds the number of items in the collection. Collection operations, called methods, include: Add (for adding a new element to a collection) Insert (for adding a new element to a collection at a specified index) Remove (for removing a specified element from a collection) Clear (for removing all the elements from a collection) Contains (for determining if a specified element is a member of a collection) Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
  • 18. Linear Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
  • 19. Linear Collections Direct Access Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
  • 20. Linear Collections Direct Access Collections Sequential Access Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
  • 21. Linear Collections Direct Access Collections Sequential Access Collections Generalized Indexed Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
  • 22. Struct DEMO Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 8 / 13
  • 23. Non Linear Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
  • 24. Non Linear Collections Hierarchical Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
  • 25. Non Linear Collections Hierarchical Collections Group Collections Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
  • 26. My Collection Class DEMO Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 10 / 13
  • 27. Generic Programming DEMO Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 11 / 13
  • 28. Oversimplified Timing Tests DEMO Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 12 / 13
  • 29. Charting in .Net DEMO Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 13 / 13