SlideShare a Scribd company logo
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 . Example:  We write a  generic  method for sorting an array of objects, then call the  generic  method with an array of any  type . The compiler performs  type   checking   to ensure that the array passed to the sorting method contains only elements of the same  type . Generics provide compile-time type safety.
Generic Methods Generic methods  enable you to specify, with a single method declaration, a set of related methods. Example:  OverloadedMethods.cs Note that the array element type (int, double or char) appears only once in each method—in the method header. If we replace the element types in each method with a generic name then all three methods would look like follows: private static void DisplayArray(  T [] inputArray ) {   foreach (  T  element in inputArray )   Console.Write( element + " " );   Console.WriteLine( "\n" ); } However, it will not compile, because its syntax is not correct. GenericMethods.cs
Generic Methods All generic method declarations have a  type-parameter list  delimited by angle brackets that follows the method’s name. Each type-parameter list contains one or more  type parameters . A type parameter is an identifier that is used in place of actual type names. The type parameters can be used to declare the return type, the parameter types and the local variable types in a generic method declaration. Type parameters act as placeholders for  type arguments  that represent the types of data that will be passed to the generic method. A generic method’s body is declared like that of any other method. The type-parameter names throughout the method declaration must match those declared in the type-parameter list. A type parameter can be declared only once in the type-parameter list but can appear more than once in the method’s parameter list. You can also use  explicit type arguments  to indicate the exact type that should be used to call a generic function, as in DisplayArray < int > ( intArray );
Generic Classes A generic class describes a class in a type-independent manner. We can then instantiate type-specific objects of the generic class. Let’s look at example:  Stack.sln StackTest.cs : repeats code in  TestPop Int / TestPopDouble   and  TestPushInt / TestPush Double How to fix this? Let’s code this together first. NewStackTest.cs
Generic Interfaces In  NewStackTest.cs , we used a generic interface: I E numerable   <   T   > Similar to generic classes,  generic interfaces  enable you to specify, with a single interface declaration, a set of related interfaces.
Common Data Structures - summary We’ve seen Array only so far    fixed-size (can grow with Resize) Dynamic data structures  can automatically grow and shrink at execution time.  Linked lists  are collections of data items that are “chained together”. Stacks  have insertions and deletions made at only one end: the top. Queues  represent waiting lines; insertions are made at the back and deletions are made from the front. Binary trees   facilitate high-speed searching and sorting of data.
Collections For the vast majority of applications, there is no need to build custom data structures. Instead, you can use the prepackaged data-structure classes provided by the .NET Framework. These classes are known as  collection   classes — they store collections of data. Each instance of one of these classes is a  collection   of items. Collection classes enable programmers to store sets of items by using existing data structures, without concern for how they are implemented. System.Collections  contains collections that store references to objects.
ArrayList The   ArrayList   collection class is a conventional arrays and provides dynamic resizing of the collection. Method / Property Description Add Adds an object to the end of the  ArrayList . Capacity Property that gets and sets the number of elements for which space is currently reserved in the ArrayList. Clear Removes all elements from the  ArrayList . Contains Determines whether an element is in the  ArrayList . Count Read-only property that gets the number of elements stored in the ArrayList. IndexOf Returns the zero-based index of the first occurrence of a value in the  ArrayList Insert Inserts an element into the  ArrayList  at the specified index. Remove Removes the first occurrence of a specific object from the  ArrayList . RemoveAt Removes the element at the specified index of the  ArrayList . TrimToSize Sets the capacity to the actual number of elements in the  ArrayList .
ArrayList Let’s write code to use  ArrayList . Suppose we have two color string arrays as follows: private static readonly string[] colors =    { &quot;MAGENTA&quot;, &quot;RED&quot;, &quot;WHITE&quot;, &quot;BLUE&quot;, &quot;CYAN&quot; }; private static readonly string[] removeColors =    { &quot;RED&quot;, &quot;WHITE&quot;, &quot;BLUE&quot; }; Let’s create an  arrayList  and add items in colors into it. Let’s display the size and capacity of  arrayList . Let’s find the index of the item “BLUE”. Let’s write a method that removes the items in one ArrayList from another. And then call that method to remove removeColors array from our first  arrayList . ArrayListTest.cs
Generic Collections Problems with Nongeneric Collections Having to store data as object references causes less efficient code due to unboxing. The .NET Framework also includes the  System.Collections.Generic  namespace, which uses C#’s generics capabilities. Many of these new classes are simply generic counterparts of the classes in namespace  System.Collections .  Generic collections eliminate the need for explicit type casts that decrease type safety and efficiency. Generic collections are especially useful for storing structs, since they eliminate the overhead of boxing and unboxing.
SortedDictionary<TKey, TValue> A  dictionary  is the general term for a collection of key/value pairs. A hash table is one way to implement a dictionary. Example: Let’s write a program that counts the number of occurrences of each word in a string read from console using  SortedDictionary . To split the sentence into words, we will use this:   // split input text into tokens string[] words = Regex.Split( input, @&quot;\s+&quot; ); http://msdn.microsoft.com/en-us/library/xfhwa508.aspx Members:  http://msdn.microsoft.com/en-us/library/3eayzh46.aspx
Collection Interfaces All collection classes in the .NET Framework implement some combination of the collection interfaces. Interface Description ICollection The root interface from which interfaces IList and IDictionary inherit. Contains a Count property to determine the size of a collection and a CopyTo method for copying a collection’s contents into a traditional array. IList An ordered collection that can be manipulated like an array. Provides an indexer for accessing elements with an int index. Also has methods for searching and modifying a collection, including Add, Remove, Contains and IndexOf. IEnumerable An object that can be enumerated. This interface contains exactly one method, GetEnumerator, which returns an IEnumerator object. ICollection implements IEnumerable, so all collection classes implement IEnumerable directly or indirectly. IDictionary A collection of values, indexed by an arbitrary “key” object. Provides an indexer for accessing elements with an object index and methods for modifying the collection (e.g., Add, Remove). IDictionary property Keys contains the objects used as indices, and property Values contains all the stored objects.
HashTable Arrays uses nonnegative integer indexes as keys. Sometimes associating these integer keys with objects to store them is impractical, so we develop a scheme for using arbitrary keys. When an application needs to store something, the scheme could convert the application  key  rapidly to an  index . Once the application has a  key  for which it wants to retrieve the data, simply apply the conversion to the key to find the array  index  where the data resides. The scheme we describe here is the basis of a technique called  hashing , in which we store data in a data structure called a  hash table .
HashTable A  hash   function  performs a calculation that determines where to place data in the hash table. The hash function is applied to the key in a key/value pair of objects. Class  Hashtable  can accept any object as a key. For this reason, class object defines method  GetHashCode , which all objects inherit. Example: Let’s write a program that counts the number of occurrences of each word in a string read from console.  To split the sentence into words, we will use this:   // split input text into tokens string[] words = Regex.Split( input, @&quot;\s+&quot; ); HashTable solution.
HashTable Hashtable method  ContainsKey  determines whether a key is in the hash table. Read-only property  Keys  returns an  ICollection  that contains all the keys. Hashtable property  Count  returns the number of key/value pairs in the Hashtable. If you use a foreach statement with a Hashtable object, the iteration variable will be of type  DictionaryEntry . The enumerator of a Hashtable (or any other class that implements  IDictionary ) uses the DictionaryEntry structure to store key/value pairs. This structure provides properties Key and Value for retrieving the key and value of the current element. If you do not need the key, class Hashtable also provides a read-only  Values  property that gets an  ICollection  of all the values stored in the Hashtable.
Stack & Queue Stack: Push Pop Peek Example: StackTest.cs Queue : Enqueue Dequeue Peek Exercise: re-write  the StackTest.cs example at home using a Queue this time.
Generic Collection Interfaces http://msdn.microsoft.com/en-us/library/system.collections.generic.aspx Interface Description ICollection(T) Defines methods to manipulate generic collections. IList(T) Represents a collection of objects that can be individually accessed by index.  IEnumerable(T) Exposes the enumerator, which supports a simple iteration over a collection of a specified type.  IEnumerator(T) Supports a simple iteration over a generic collection.  IDictionary(TKey,TValue) Represents a generic collection of key/value pairs. IComparer(T) Defines a method that a type implements to compare two objects.
Other Generic Collection Classes List(T) Let’s re-write the ArrayListTest.cs using List<T> this time. Stack(T) Queue(T) LinkedList(T) SortedList(TKey, TValue)

More Related Content

PPT
Ap Power Point Chpt6
PPT
Ap Power Point Chpt9
PDF
Java collections-interview-questions
PDF
Java Collections
PDF
LectureNotes-06-DSA
PDF
LectureNotes-03-DSA
PPT
Generics collections
Ap Power Point Chpt6
Ap Power Point Chpt9
Java collections-interview-questions
Java Collections
LectureNotes-06-DSA
LectureNotes-03-DSA
Generics collections

What's hot (20)

PDF
Java Collections Tutorials
PPT
Md08 collection api
PDF
07 java collection
PPT
Java collections concept
PPTX
Java - Collections framework
PPTX
Array list(1)
PDF
LectureNotes-05-DSA
PDF
Collections Api - Java
PDF
Collections In Java
PPT
java collections
ODP
Java Collections
PPT
Collections in Java
PPT
Collection Framework in java
PDF
5 collection framework
PDF
Collection framework (completenotes) zeeshan
PPT
Java collection
DOCX
Java collections notes
PDF
Collections in Java Notes
PPTX
Collections framework in java
Java Collections Tutorials
Md08 collection api
07 java collection
Java collections concept
Java - Collections framework
Array list(1)
LectureNotes-05-DSA
Collections Api - Java
Collections In Java
java collections
Java Collections
Collections in Java
Collection Framework in java
5 collection framework
Collection framework (completenotes) zeeshan
Java collection
Java collections notes
Collections in Java Notes
Collections framework in java
Ad

Similar to Generics Collections (20)

PPTX
C# Non generics collection
PPTX
COLLECTIONS.pptx
PPTX
Collections in .net technology (2160711)
PPTX
Generic Programming &amp; Collection
PPTX
Generic Programming &amp; Collection
PPTX
CSharp for Unity - Day 1
PPTX
Collection
PDF
C# quick ref (bruce 2016)
DOCX
Collections generic
PPSX
Net framework session02
PPT
Collections
PPTX
9collection in c#
DOCX
C# Collection classes
PPTX
Collections and its types in C# (with examples)
PPS
Net framework session02
PPTX
Module 8 : Implementing collections and generics
PDF
Dictionary and sets-converted
PPT
Advanced c#
PDF
1204csharp
PDF
Amusing C#
C# Non generics collection
COLLECTIONS.pptx
Collections in .net technology (2160711)
Generic Programming &amp; Collection
Generic Programming &amp; Collection
CSharp for Unity - Day 1
Collection
C# quick ref (bruce 2016)
Collections generic
Net framework session02
Collections
9collection in c#
C# Collection classes
Collections and its types in C# (with examples)
Net framework session02
Module 8 : Implementing collections and generics
Dictionary and sets-converted
Advanced c#
1204csharp
Amusing C#
Ad

More from phanleson (20)

PDF
Learning spark ch01 - Introduction to Data Analysis with Spark
PPT
Firewall - Network Defense in Depth Firewalls
PPT
Mobile Security - Wireless hacking
PPT
Authentication in wireless - Security in Wireless Protocols
PPT
E-Commerce Security - Application attacks - Server Attacks
PPT
Hacking web applications
PPTX
HBase In Action - Chapter 04: HBase table design
PPT
HBase In Action - Chapter 10 - Operations
PPT
Hbase in action - Chapter 09: Deploying HBase
PPTX
Learning spark ch11 - Machine Learning with MLlib
PPTX
Learning spark ch10 - Spark Streaming
PPTX
Learning spark ch09 - Spark SQL
PPT
Learning spark ch07 - Running on a Cluster
PPTX
Learning spark ch06 - Advanced Spark Programming
PPTX
Learning spark ch05 - Loading and Saving Your Data
PPTX
Learning spark ch04 - Working with Key/Value Pairs
PPTX
Learning spark ch01 - Introduction to Data Analysis with Spark
PPT
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
PPT
Lecture 1 - Getting to know XML
PPTX
Lecture 4 - Adding XTHML for the Web
Learning spark ch01 - Introduction to Data Analysis with Spark
Firewall - Network Defense in Depth Firewalls
Mobile Security - Wireless hacking
Authentication in wireless - Security in Wireless Protocols
E-Commerce Security - Application attacks - Server Attacks
Hacking web applications
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 10 - Operations
Hbase in action - Chapter 09: Deploying HBase
Learning spark ch11 - Machine Learning with MLlib
Learning spark ch10 - Spark Streaming
Learning spark ch09 - Spark SQL
Learning spark ch07 - Running on a Cluster
Learning spark ch06 - Advanced Spark Programming
Learning spark ch05 - Loading and Saving Your Data
Learning spark ch04 - Working with Key/Value Pairs
Learning spark ch01 - Introduction to Data Analysis with Spark
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Lecture 1 - Getting to know XML
Lecture 4 - Adding XTHML for the Web

Recently uploaded (20)

PDF
A Day in the Life of Location Data - Turning Where into How.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Google’s NotebookLM Unveils Video Overviews
PDF
REPORT: Heating appliances market in Poland 2024
PPTX
CroxyProxy Instagram Access id login.pptx
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
PPTX
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Event Presentation Google Cloud Next Extended 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
DevOps & Developer Experience Summer BBQ
PDF
creating-agentic-ai-solutions-leveraging-aws.pdf
A Day in the Life of Location Data - Turning Where into How.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Understanding_Digital_Forensics_Presentation.pptx
Google’s NotebookLM Unveils Video Overviews
REPORT: Heating appliances market in Poland 2024
CroxyProxy Instagram Access id login.pptx
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Reimagining Insurance: Connected Data for Confident Decisions.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Automating ArcGIS Content Discovery with FME: A Real World Use Case
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Modernizing your data center with Dell and AMD
Event Presentation Google Cloud Next Extended 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
DevOps & Developer Experience Summer BBQ
creating-agentic-ai-solutions-leveraging-aws.pdf

Generics Collections

  • 2. 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 . Example: We write a generic method for sorting an array of objects, then call the generic method with an array of any type . The compiler performs type checking to ensure that the array passed to the sorting method contains only elements of the same type . Generics provide compile-time type safety.
  • 3. Generic Methods Generic methods enable you to specify, with a single method declaration, a set of related methods. Example: OverloadedMethods.cs Note that the array element type (int, double or char) appears only once in each method—in the method header. If we replace the element types in each method with a generic name then all three methods would look like follows: private static void DisplayArray( T [] inputArray ) { foreach ( T element in inputArray ) Console.Write( element + &quot; &quot; ); Console.WriteLine( &quot;\n&quot; ); } However, it will not compile, because its syntax is not correct. GenericMethods.cs
  • 4. Generic Methods All generic method declarations have a type-parameter list delimited by angle brackets that follows the method’s name. Each type-parameter list contains one or more type parameters . A type parameter is an identifier that is used in place of actual type names. The type parameters can be used to declare the return type, the parameter types and the local variable types in a generic method declaration. Type parameters act as placeholders for type arguments that represent the types of data that will be passed to the generic method. A generic method’s body is declared like that of any other method. The type-parameter names throughout the method declaration must match those declared in the type-parameter list. A type parameter can be declared only once in the type-parameter list but can appear more than once in the method’s parameter list. You can also use explicit type arguments to indicate the exact type that should be used to call a generic function, as in DisplayArray < int > ( intArray );
  • 5. Generic Classes A generic class describes a class in a type-independent manner. We can then instantiate type-specific objects of the generic class. Let’s look at example: Stack.sln StackTest.cs : repeats code in TestPop Int / TestPopDouble and TestPushInt / TestPush Double How to fix this? Let’s code this together first. NewStackTest.cs
  • 6. Generic Interfaces In NewStackTest.cs , we used a generic interface: I E numerable < T > Similar to generic classes, generic interfaces enable you to specify, with a single interface declaration, a set of related interfaces.
  • 7. Common Data Structures - summary We’ve seen Array only so far  fixed-size (can grow with Resize) Dynamic data structures can automatically grow and shrink at execution time. Linked lists are collections of data items that are “chained together”. Stacks have insertions and deletions made at only one end: the top. Queues represent waiting lines; insertions are made at the back and deletions are made from the front. Binary trees facilitate high-speed searching and sorting of data.
  • 8. Collections For the vast majority of applications, there is no need to build custom data structures. Instead, you can use the prepackaged data-structure classes provided by the .NET Framework. These classes are known as collection classes — they store collections of data. Each instance of one of these classes is a collection of items. Collection classes enable programmers to store sets of items by using existing data structures, without concern for how they are implemented. System.Collections contains collections that store references to objects.
  • 9. ArrayList The ArrayList collection class is a conventional arrays and provides dynamic resizing of the collection. Method / Property Description Add Adds an object to the end of the ArrayList . Capacity Property that gets and sets the number of elements for which space is currently reserved in the ArrayList. Clear Removes all elements from the ArrayList . Contains Determines whether an element is in the ArrayList . Count Read-only property that gets the number of elements stored in the ArrayList. IndexOf Returns the zero-based index of the first occurrence of a value in the ArrayList Insert Inserts an element into the ArrayList at the specified index. Remove Removes the first occurrence of a specific object from the ArrayList . RemoveAt Removes the element at the specified index of the ArrayList . TrimToSize Sets the capacity to the actual number of elements in the ArrayList .
  • 10. ArrayList Let’s write code to use ArrayList . Suppose we have two color string arrays as follows: private static readonly string[] colors = { &quot;MAGENTA&quot;, &quot;RED&quot;, &quot;WHITE&quot;, &quot;BLUE&quot;, &quot;CYAN&quot; }; private static readonly string[] removeColors = { &quot;RED&quot;, &quot;WHITE&quot;, &quot;BLUE&quot; }; Let’s create an arrayList and add items in colors into it. Let’s display the size and capacity of arrayList . Let’s find the index of the item “BLUE”. Let’s write a method that removes the items in one ArrayList from another. And then call that method to remove removeColors array from our first arrayList . ArrayListTest.cs
  • 11. Generic Collections Problems with Nongeneric Collections Having to store data as object references causes less efficient code due to unboxing. The .NET Framework also includes the System.Collections.Generic namespace, which uses C#’s generics capabilities. Many of these new classes are simply generic counterparts of the classes in namespace System.Collections . Generic collections eliminate the need for explicit type casts that decrease type safety and efficiency. Generic collections are especially useful for storing structs, since they eliminate the overhead of boxing and unboxing.
  • 12. SortedDictionary<TKey, TValue> A dictionary is the general term for a collection of key/value pairs. A hash table is one way to implement a dictionary. Example: Let’s write a program that counts the number of occurrences of each word in a string read from console using SortedDictionary . To split the sentence into words, we will use this: // split input text into tokens string[] words = Regex.Split( input, @&quot;\s+&quot; ); http://msdn.microsoft.com/en-us/library/xfhwa508.aspx Members: http://msdn.microsoft.com/en-us/library/3eayzh46.aspx
  • 13. Collection Interfaces All collection classes in the .NET Framework implement some combination of the collection interfaces. Interface Description ICollection The root interface from which interfaces IList and IDictionary inherit. Contains a Count property to determine the size of a collection and a CopyTo method for copying a collection’s contents into a traditional array. IList An ordered collection that can be manipulated like an array. Provides an indexer for accessing elements with an int index. Also has methods for searching and modifying a collection, including Add, Remove, Contains and IndexOf. IEnumerable An object that can be enumerated. This interface contains exactly one method, GetEnumerator, which returns an IEnumerator object. ICollection implements IEnumerable, so all collection classes implement IEnumerable directly or indirectly. IDictionary A collection of values, indexed by an arbitrary “key” object. Provides an indexer for accessing elements with an object index and methods for modifying the collection (e.g., Add, Remove). IDictionary property Keys contains the objects used as indices, and property Values contains all the stored objects.
  • 14. HashTable Arrays uses nonnegative integer indexes as keys. Sometimes associating these integer keys with objects to store them is impractical, so we develop a scheme for using arbitrary keys. When an application needs to store something, the scheme could convert the application key rapidly to an index . Once the application has a key for which it wants to retrieve the data, simply apply the conversion to the key to find the array index where the data resides. The scheme we describe here is the basis of a technique called hashing , in which we store data in a data structure called a hash table .
  • 15. HashTable A hash function performs a calculation that determines where to place data in the hash table. The hash function is applied to the key in a key/value pair of objects. Class Hashtable can accept any object as a key. For this reason, class object defines method GetHashCode , which all objects inherit. Example: Let’s write a program that counts the number of occurrences of each word in a string read from console. To split the sentence into words, we will use this: // split input text into tokens string[] words = Regex.Split( input, @&quot;\s+&quot; ); HashTable solution.
  • 16. HashTable Hashtable method ContainsKey determines whether a key is in the hash table. Read-only property Keys returns an ICollection that contains all the keys. Hashtable property Count returns the number of key/value pairs in the Hashtable. If you use a foreach statement with a Hashtable object, the iteration variable will be of type DictionaryEntry . The enumerator of a Hashtable (or any other class that implements IDictionary ) uses the DictionaryEntry structure to store key/value pairs. This structure provides properties Key and Value for retrieving the key and value of the current element. If you do not need the key, class Hashtable also provides a read-only Values property that gets an ICollection of all the values stored in the Hashtable.
  • 17. Stack & Queue Stack: Push Pop Peek Example: StackTest.cs Queue : Enqueue Dequeue Peek Exercise: re-write the StackTest.cs example at home using a Queue this time.
  • 18. Generic Collection Interfaces http://msdn.microsoft.com/en-us/library/system.collections.generic.aspx Interface Description ICollection(T) Defines methods to manipulate generic collections. IList(T) Represents a collection of objects that can be individually accessed by index. IEnumerable(T) Exposes the enumerator, which supports a simple iteration over a collection of a specified type. IEnumerator(T) Supports a simple iteration over a generic collection. IDictionary(TKey,TValue) Represents a generic collection of key/value pairs. IComparer(T) Defines a method that a type implements to compare two objects.
  • 19. Other Generic Collection Classes List(T) Let’s re-write the ArrayListTest.cs using List<T> this time. Stack(T) Queue(T) LinkedList(T) SortedList(TKey, TValue)