我有一个快速应用程序需要使用SortedList。由于我没有经常使用它,所以我进行了一些研究,以确保我知道我在做什么,结果发现似乎有两个版本。还是说有一个带有附加功能的SortedList?你会发现一个版本在System.Collections中,另一个版本在System.Collections.Generic中。
System.Collections.SortedList slist1 = new SortedList();
System.Collections.Generic.SortedList<string, object> slist2 = new SortedList<string, object>();
它们在许多方面都有所不同。slist1有一个SetByIndex方法,而slist2没有。
那么,为什么会有两个版本的SortedList呢?如何更新通用SortedList中对象的值呢?
SortedList<TKey, TValue>
之外,还有一个通用的SortedDictionary<TKey, Value>
。它们仅在内部实现上有所不同(因此时间/空间复杂度也不同)。 - Ivan Stoev