Is there a collection in .NET that combines the functionality of both a List and a Dictionary?
-
Hi gurus, I'm looking for a collection that combines the functionality of a list and dictionary. I basically want to be able to keep the order in which the items are added and at the same time do fast lookup? O(log n) as opposed to O(n), does this thing exist or do I have to write it myself? Regards
Waleed Eissa Software Developer Sydney
-
Hi gurus, I'm looking for a collection that combines the functionality of a list and dictionary. I basically want to be able to keep the order in which the items are added and at the same time do fast lookup? O(log n) as opposed to O(n), does this thing exist or do I have to write it myself? Regards
Waleed Eissa Software Developer Sydney
If you can use a SortedDictionary, it's loopup is a O(log n) operation. Otherwise you need to write it yourself. Just wrap a List and a Dictionary in a class, write an Add method that adds an item to both collections, and properties to get the values by index and by key.
Despite everything, the person most likely to be fooling you next is yourself.
-
Hi gurus, I'm looking for a collection that combines the functionality of a list and dictionary. I basically want to be able to keep the order in which the items are added and at the same time do fast lookup? O(log n) as opposed to O(n), does this thing exist or do I have to write it myself? Regards
Waleed Eissa Software Developer Sydney
Guess you have to write it yourself, like KeyList with members List and Dictionary to which you delegate. But then I'm not a guru...
-
Hi gurus, I'm looking for a collection that combines the functionality of a list and dictionary. I basically want to be able to keep the order in which the items are added and at the same time do fast lookup? O(log n) as opposed to O(n), does this thing exist or do I have to write it myself? Regards
Waleed Eissa Software Developer Sydney
Thanks guys for your replies, seems like I'll have to write myself .. just wanted to be sure I'm not wasting my time in reinventing the wheel ..
Waleed Eissa Software Developer Sydney
-
Thanks guys for your replies, seems like I'll have to write myself .. just wanted to be sure I'm not wasting my time in reinventing the wheel ..
Waleed Eissa Software Developer Sydney
-
Does
SortedList
in the System.Collections.Generic namespace not work for you? It has a GetByIndex method along with key lookup!Thanks for your reply, actually I want to keep the same order in which items are inserted, this is why SortedListed and SortedDictionary are not suitable for the job ..
Waleed Eissa Software Developer Sydney