Category Archive for: Collections

Performance

Many collection classes offer the same functionality as others; for example, SortedList offers nearly the same features as SortedDictionary. However, often there’s a big difference in performance. Whereas one collection consumes less memory, the other collection class is faster with retrieval of elements. In the MSDN documentation, you often find performance hints with methods of the collection giving…

Read More →

Bit Arrays

If you need to deal with a number of bits, you can use the class :Array can the struct  BitVector32. BitArray is located in the namespace System.  BitVector32 is 4th the namespace System. Collect ions. Specialized. The difference between these two types is that Bit Array is resizable, which is useful 4,9/large number ,number of bits needed in advance, and…

Read More →

HashSet

.NET 3.5 includes a new collection class in the System. Collections. Generic namespace: HashSet<T>. This collection class contains an unordered list of distinct items. Such a collection is known by the term set. Because set is a reserved word, the class has a different name: HashSet<T>. The name was easily decided because this collection is based on hash…

Read More →

Dictionaries

Dictionaries represent a sophisticated data structure that allows you to access an element based on a key. Dictionaries are also known as hash tables or maps. The main feature of dictionaries is fast lookup based on keys. You can also add and remove items freely. a bit like a List<T>, but without the performance overhead of having to…

Read More →

Sorted Lists

If you need a sorted list, you can use SortedList<TKey, TValue>. This class sorts the elements based on a key. The example creates a sorted list where both the key and the value are of type string. The default . constructor creates an empty list, and then two books are added with the Add () method. With…

Read More →

Linked Lists

Acollection class that has no similar version with a non-generic collection is LinkedList<T>. LinkedList<T> is a doubly linked list, where one element references the next and the previous one, as shown. The advantage of a linked list is that if items are inserted in the middle of a list, the linked list is very fast. When an item…

Read More →

Stacks

A stack is another container that is very similar to the queue. You just use different methods to access the stack. The item that is added last to the stack is read first. The stack is a last in,first out (LIFO) container. It shows the representation of a stack where the Push () method adds an…

Read More →

Queues

A queue is a collection where elements are processed first in,first out (FIFO). The item that is put first in the queue is read first. Examples of queues are standing in the queue at the airport, a human resources queue to process employee applicants, print jobs waiting to be processed in a print queue, and a thread waiting…

Read More →

Lists

For dynamic lists, the.NET Framework offers the classes ArrayList and List<T>.The class List<T> in the namespace System .:collections.Generic is very similar in its usage to the ArrayList class from the namespace System.Collections.This class implements the IList,ICollection~and IEnumerable interfaces. already discussed the methods of these interfaces,thissectionlooks athow to use the List<T> class. The following examples use the members of the…

Read More →

Collection Interfaces and Types

Collection classes can be grouped into collections that store elements of type Object and generic collection classes. Previous to CLR 2.0, generics didn’t exist. Now the generic collection classes usually are the preferred type’ of collection. Generic collection classes are type-safe, and there is no boxing if value types are used. You need object-based collection classes only if…

Read More →

Back to Top