Wednesday, October 3, 2007

A alphabetized HashTable

Due to the way a HashTable stores its keys and values they can't be natively alphabetized; it is optimized as a lookup system and that is what it is good at.

Other languages have objects like the TreeMap which can then be walked to be the items in sorted order.

In .NET if you want the functionality of the HashTable but have your list indexed on key rather than hash value, then you have to use the SortedList object. Personally I don't like the name, but I love the functionality, it is a great tool to be aware of.

It's namespace is:
System.Collections.SortedList

No comments: