SlideShare a Scribd company logo
1 of 29
Download to read offline
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

More from Getachew Ganfur

Labmanualc2ndedition2 2-121115034959-phpapp02
Labmanualc2ndedition2 2-121115034959-phpapp02Labmanualc2ndedition2 2-121115034959-phpapp02
Labmanualc2ndedition2 2-121115034959-phpapp02Getachew Ganfur
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01Getachew Ganfur
 
Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Getachew Ganfur
 
Ds 111011055724-phpapp01
Ds 111011055724-phpapp01Ds 111011055724-phpapp01
Ds 111011055724-phpapp01Getachew Ganfur
 
Datastructurenotes 100627004340-phpapp01
Datastructurenotes 100627004340-phpapp01Datastructurenotes 100627004340-phpapp01
Datastructurenotes 100627004340-phpapp01Getachew Ganfur
 
Datastructureanditstypes 110410094332-phpapp02
Datastructureanditstypes 110410094332-phpapp02Datastructureanditstypes 110410094332-phpapp02
Datastructureanditstypes 110410094332-phpapp02Getachew Ganfur
 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Getachew Ganfur
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Getachew Ganfur
 

More from Getachew Ganfur (10)

Labmanualc2ndedition2 2-121115034959-phpapp02
Labmanualc2ndedition2 2-121115034959-phpapp02Labmanualc2ndedition2 2-121115034959-phpapp02
Labmanualc2ndedition2 2-121115034959-phpapp02
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
 
Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02
 
Ds 111011055724-phpapp01
Ds 111011055724-phpapp01Ds 111011055724-phpapp01
Ds 111011055724-phpapp01
 
Document(1)
Document(1)Document(1)
Document(1)
 
Datastructurenotes 100627004340-phpapp01
Datastructurenotes 100627004340-phpapp01Datastructurenotes 100627004340-phpapp01
Datastructurenotes 100627004340-phpapp01
 
Datastructureanditstypes 110410094332-phpapp02
Datastructureanditstypes 110410094332-phpapp02Datastructureanditstypes 110410094332-phpapp02
Datastructureanditstypes 110410094332-phpapp02
 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
 
1to5 4th
1to5 4th1to5 4th
1to5 4th
 

Collections and Generics Dr El-Ghareeb CIS Mansoura University

  • 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