开发者

Is there any alternative of Dictionary in .NET?

I have a requirement of using a dictionary in the project but as we know that they are only accessible using the keys and not using the indexes, and I want to access the items in dictionary using indexes. So I fiddle over the web and found out about OrderedDictionary as they are accessible using both the indexes and keys but they have some performance issue and as I am reading/writing the dictionary every minute of the day so it's not a good idea to use OrderedDictionary.

So lastly my question in here is that is there any alternative available which gives me functionality of Dictionary and I can also access it using indexes and doesn't cause a perfo开发者_如何学运维rmance issue.


SortedList<TKey, TValue> has a property, Values, that is an IList<TValue>. Is it enough? It's fast only for small "sets" of elements. The difference with SortedDictionary is here http://msdn.microsoft.com/en-us/library/5z658b67(v=vs.80).aspx

Can I ask you why you want to access it "by index"? You can still enumerate it with foreach, you know?


in response to your comment that you are only expecting a hundred updates a minute, this is very little work - practically nothing. You can still use an OrderedDictionary, performance will not be an issue for you.


Try SortedDictionary http://msdn.microsoft.com/en-us/library/f7fta44c.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜