Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Sealed class: RT.Util.Collections.ListSorted<T>

Summary

Implements a list whose items are always stored in a sorted order. Multiple equal items are allowed, and will always be added to the end of a run of equal items. Insertion, and removal are O(N); lookups are O(log N); access by index is supported.

Generic type parameters

TThis type parameter is not documented.

Constructors

Creates an empty ListSorted<T> using a default comparer for the item type.
ListSorted<T>(int capacity)
Creates an empty ListSorted<T> of the specified capacity and using a default comparer for the item type.
ListSorted<T>(IComparer<T> comparer)
Creates an empty ListSorted<T> using the specified item comparer.
ListSorted<T>(int capacity, IComparer<T> comparer)
Creates an empty ListSorted<T> of the specified capacity and using the specified item comparer.

Instance methods

void
Add(T item)
  • Implements: ICollection<T>.Add(T)
Adds the specified item to the list. The item is added at the appropriate location to keep the list sorted. If multiple equal items are stored, this method is guaranteed to add an item at the end of the equal items run. This method is O(N).
void
AddRange(IEnumerable<T> collection)
Adds all of the specified items into the list. The resulting list will contain all the items in the same order as a stable sort would have produced. NOTE: the current implementation is O(N log N) if the collection is empty, or O(N*M) otherwise, where N = items currently in the collection and M = items to be added. The latter can be improved.
void
  • Implements: ICollection<T>.Clear()
Removes all items from the list.
bool
Contains(T item)
  • Implements: ICollection<T>.Contains(T)
Returns true if the list contains the specified item. This operation is O(logN).
void
CopyTo(T[] array, int arrayIndex)
  • Implements: ICollection<T>.CopyTo(T[], int)
Copies all items of this collection into the specified array, starting at the specified index, in the sorted order.
IEnumerator<T>
  • Implements: IEnumerable<T>.GetEnumerator()
Gets an enumerator which enumerates all items of this collection in sorted order.
int
IndexOf(T item)
  • Implements: IList<T>.IndexOf(T)
Returns the index of the FIRST item equal to the specified item, or -1 if the item is not found. The operation is O(log N).
int
LastIndexOf(T item)
Returns the index of the LAST item equal to the specified item, or -1 if the item is not found. The operation is O(log N).
bool
Remove(T item)
  • Implements: ICollection<T>.Remove(T)
Removes the FIRST occurrence of the specified item from the list. Returns true if the item was removed, or false if it wasn't found.
void
RemoveAt(int index)
  • Implements: IList<T>.RemoveAt(int)
Removes the item at the specified index.
bool
RemoveLast(T item)
Removes the LAST occurrence of the specified item from the list. Returns true if the item was removed, or false if it wasn't found.

Instance properties

int
  • Implements: ICollection<T>.Count
Gets the number of items stored in this collection.
bool
  • Implements: ICollection<T>.IsReadOnly
Returns false.
T
this[int index]
  • Implements: IList<T>.this[int]
Gets an item at the specified index. Setting an item is not supported and will always throw an exception.