a.
Stack:
·
FILO (first in last out)
·
Push(object
o) – insert an object at top of stack
·
POP()
– removes object at top of stack
·
Peek()
– returns object at top of stack without removing
·
One of the classic examples of stack in .net
framework is in memory management of value types.
·
There are non
generic collection stack object (System.Collections.Stack)
and generic collection stack object
(System.Collections.Generic.Stack )
b.
Queue:
·
FIFO
·
Enqueue(object
o) – add an object at end of queue
·
Dequeue()
– remove object at beginning of queue
·
Peek() -
return object at beginning of queue
·
First object entering to the Queue, exits first
·
One of the classic example of queue
implementation in MSMQ
·
Queue is used in the highly reliable
communication scenarios. Even if the message channel not available, messages
are stored in the queue and transmitted once the channel is up.
·
There are non
generic collection object (System.Collections.Queue)
and generic collection object (System.Collections.Generic. Queue )
c.
Hashtable
·
Hashtable stores key – value pair
·
Is organized based on the hash code of the key
·
Each element in hashtable is stored as DictionaryEntry object
·
A key cannot be null, but value can be
·
It is a non
generic collection System.Collections type
·
Hashtable stores types of object
·
There is a type conversion required every time
when we use hashtable
IDictionary,
ICollection, IEnumerable,
ISerializable, IDeserializationCallback,
ICloneable
d.
Dictionary
·
Dictionary is similar to Hashtable (key-value
pair storage)
·
It is a generic
collection (System.Collections.Generics)
·
Type of the object to store in the dictionary
should specify at compile time
·
Performance wise, Dictionary is better option that Hashtable
IDictionary, ICollection<KeyValuePair>, IEnumerable<KeyValuePair>, IDictionary, ICollection, IEnumerable,
ISerializable, IDeserializationCallback
e.
List
·
It is generics collection (System.Collections. Generics)
·
It represents strongly typed list of objects
·
Consider a scenario to store all the employee
names of Satyam, then use List
·
No type conversion required hence preferred over
ArrayList
IList, ICollection, IEnumerable, IList,
ICollection, IEnumerable
f.
ArrayList
·
ArrayList is a non generic collection (System.Collections)
·
Size can be dynamically increase
·
ArrayList stores objects
·
Type conversion required every time when use AL
· This affects the performance
· This affects the performance
No comments:
Post a Comment