SortedList
SortedList is a data structure that maintains its elements in a sorted order. It is often implemented using an array or a similar contiguous memory structure where elements are automatically kept in ascending or descending order. When a new element is added, the SortedList finds its correct position and inserts it, shifting existing elements as needed to preserve the sorted property. Similarly, removing an element involves locating it and then closing the gap left behind.
The primary advantage of a SortedList is efficient searching. Because the elements are ordered, algorithms like
However, insertion and deletion operations can be less efficient than in unsorted lists. Depending on the implementation,