Download presentation
Presentation is loading. Please wait.
Published byBeverley Bradley Modified over 8 years ago
1
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Collections Presented By : Muhammad Atif Hussain Deputy Manager IT (Takaful Pakistan Limited) Technologies Consultant (AUC Technologies) MCS(KU) MSCS(SZABIST) MCP MCAD MCSD MCTS (Windows, Web, Distributed Applications) MCPD (Enterprise Applications) MCT(Microsoft Certified Trainer)
2
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Data Structure Types of Data structure Examples Agenda
3
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Collection of Objects Memory Representation of Data Data Structure
4
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Array ArrayList List<> LinkedList<> Dictionary HashTable HashSet Stack Queue Type of Data Structure (System.Collections)
5
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Array Most common and simplest List of Objects All the Objects are of same types Specified number of Objects [object type][] myArray = new [object type][number of elements] Examples int[] myIntArray = new int[5]; int[] myIntArray2 = { 0, 1, 2, 3, 4 };
6
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company ArrayList Dynamic Array Any type of Objects Any amount of Objects Expanded as more item are added Casting required when value retrieved Examples: ArrayList myArrayList = new ArrayList(); myArrayList.Add(56); myArrayList.Add("String"); int arrayListValue = (int)myArrayList[0];
7
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Typed ArrayList Dynamic Array Same type of Objects Examples: List intList = new List (); intList.Add(45); intList.Add(34); int listValue = intList[0]; Hint: For primative data types (int, bool, etc.) using a List is much faster than ArrayList List<>
8
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Series of Objects linked together in Nodes – Object Value – Next Node – Previous Node Adding values in the middle of the list is extremely fast Memory cost down to minimum Retrieving a value is not a straight forward Examples: LinkedList list = newLinkedList (); list.AddLast(6); LinkedList<>
9
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Programmer can handle index at their own Keys is also an Object Retrieving a value is pretty straight forward Examples: Dictionary myDictionary = new Dictionary (); myDictionary.Add("one", 1); myDictionary.Add("twenty", 20); int myInt = myDictionary["one"]; Dictionary<>
10
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Similar to Dictionary Data Structure Also takes in Key/Value pair but generic Objects opposed to typed data Values are stored in order of HashCode (Key) but Dictionary does keep items in the same order HashTable stores items faster than a Dictionary Examples: Hashtable myTable = new Hashtable(); myTable.Add("name", "Vb.NET"); myTable.Add(1, "C#.NET"); HashTable
11
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Introduced in.NET Framework 3.5 Resemble to List<> Data structure Its does not allow duplicate value Examples: HashSet mySet = new HashSet (); mySet.Add(3); mySet.Add(5); List myListFromSet = mySet.ToList (); int myInt = myListFromSet[1]; HashSet
12
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Resemble to ArrayList Push (Add), Pop (Get), LIFO Stack works with Objects, Stack<> works with specified Object Examples: Stack stack = new Stack(); stack.Push("1"); stack.Push("2"); stack.Push("3"); while (stack.Count > 0){MessageBox.Show(stack.Pop());} Stack and Stack<>
13
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Very similar to Stack Enqueue (Add), Dequeue (Remove) Queues goes by FIFO Examples: Queue queue = new Queue (); queue.Enqueue("1"); queue.Enqueue("2"); queue.Enqueue("3"); while (queue.Count > 0){MessageBox.Show(queue.Dequeue());} Queue
14
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company
15
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Questions ?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.