This document discusses collections and generics. It defines a collection as a structured data type that stores data and provides operations for adding, removing, and updating data. Collections are categorized as either linear or nonlinear. Linear collections have elements ordered by position, while nonlinear collections do not have positional ordering. The document also covers collection properties like count, and common collection methods like add, insert, and remove. It provides examples of different types of linear and nonlinear collections.
1 of 29
Download to read offline
More Related Content
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
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
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
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