Monday, 17 December 2012

c sharp programming

OrderedDictionary
An OrderedDictionary is a nongeneric dictionary that maintains elements in the same
order that they were added. With an OrderedDictionary, you can access elements
both by index and by key.
An OrderedDictionary is not a sorted dictionary.
An OrderedDictionary  is a combination of a Hashtable and an ArrayList. This means
it has all the functionality of a Hashtable, plus functions such as RemoveAt, as well as
an integer indexer. It also exposes Keys and Values properties that return elements
in their original order.
This class was introduced in .NET 2.0, yet peculiarly, there’s no generic version.

ListDictionary and HybridDictionary
ListDictionary uses a singly linked list to store the underlying data. It doesn’t pro-
vide  sorting,  although  it  does  preserve  the  original  entry  order  of  the  items.
ListDictionary is extremely slow with large lists. Its only real “claim to fame” is its
efficiency with very small lists (fewer than 10 items).
HybridDictionary  is  a  ListDictionary  that  automatically  converts  to  a  Hashtable
upon reaching a certain size, to address ListDictionary’s problems with perform-
ance. The idea is to get a low memory footprint when the dictionary is small, and
good performance when  the dictionary  is  large. However, given  the overhead  in
converting from one to the other—and the fact that a Dictionary is not excessively
heavy  or  slow  in  either  scenario—you wouldn’t  suffer  unreasonably  by  using  a
Dictionary to begin with.
Both classes come only in nongeneric form.

No comments:

Post a Comment