SortedList

  • SortedList<TKey, TValue> stores key value pairs in sorted order

  • The Values can be accessed with the key or index

  • The SortedList can be iterated over

  • The sorted list utilizes two lists to store the data. One list for the keys and other list for the values

  • SortedList<TKey, TValue>.Add(key, value) - Worst case is O(n)

  • SortList<TKey, TValue>.Remove(key) -> O(n)

  • Iterating over -> O(c) per element

  • data[key] (retrieving) -> O(log n)

  • data[key] (replacing) -> O(log n)

  • data[key] (setting) -> O(n)