Enhanced C#
Language of your choice: library documentation
|
This class contains extension methods that are provided as part of various Loyc.Collections interfaces. For example, it provides methods such as IndexOf(), Contains() and CopyTo(), that the traditional ICollection{T} and IList{T} interfaces require the author to write himself. More...
This class contains extension methods that are provided as part of various Loyc.Collections interfaces. For example, it provides methods such as IndexOf(), Contains() and CopyTo(), that the traditional ICollection{T} and IList{T} interfaces require the author to write himself.
Extension methods for Loyc collection interfaces
For covariant collections such as IReadOnlyCollection{T} and IListSource{T}, the CLR actually prohibits methods such as Contains(T) and IndexOf(T), because T is not allowed in "input" positions. Therefore, these extension methods must be used to fill the gap. Even methods such as bool TryGet(int, out T) are prohibited, so TryGet() has the signature T TryGet(ref bool failed) instead, and extension methods provide the original version of the method in addition.
Static Public Member Functions | |
static bool | Any (this ICount c) |
Returns true if the collection contains any elements. More... | |
static bool | TryGet< T > (this IListSource< T > list, int index, ref T value) |
Tries to get a value from the list at the specified index. More... | |
static T | TryGet< T > (this IListSource< T > list, int index, T defaultValue) |
Tries to get a value from the list at the specified index. More... | |
static Maybe< T > | TryGet< T > (this IListSource< T > list, int index) |
Tries to get a value from the list at the specified index. More... | |
static bool | HasIndex< T > (this IListSource< T > list, int index) |
Uses list.TryGet(index) to find out if the specified index is valid. More... | |
static int | IndexOf< T > (this IReadOnlyList< T > list, T item) |
Determines the index of a specific value. More... | |
static void | CopyTo< T > (this IReadOnlyList< T > c, T[] array, int arrayIndex) |
static int | IndexWhere< T > (this IReadOnlyList< T > source, Func< T, bool > pred) |
Gets the lowest index at which a condition is true, or -1 if nowhere. More... | |
static int | LastIndexWhere< T > (this IReadOnlyList< T > source, Func< T, bool > pred) |
Gets the highest index at which a condition is true, or -1 if nowhere. More... | |
static T[] | ToArray< T > (this IReadOnlyList< T > c) |
Copies the contents of an IListSource to an array. More... | |
static T | LastOrDefault< T > (this IReadOnlyList< T > list) |
static T | FirstOrDefault< T > (this IReadOnlyList< T > list) |
static T | FirstOrDefault< T > (this IListSource< T > list) |
static bool | TryGet< T > (this INegListSource< T > list, int index, ref T value) |
Tries to get a value from the list at the specified index. More... | |
static T | TryGet< T > (this INegListSource< T > list, int index, T defaultValue) |
Tries to get a value from the list at the specified index. More... | |
static int | IndexOf< T > (this INegListSource< T > list, T item) |
Determines the index of a specific value. More... | |
static int | NextHigherIndex< T > (this ISparseListSource< T > list, int?index) |
Gets the next higher index that is not classified as an empty space, or null if there are no non-blank higher indexes. More... | |
static int | NextLowerIndex< T > (this ISparseListSource< T > list, int?index) |
Gets the next lower index that is not classified as an empty space, or null if there are no non-blank lower indexes. More... | |
static IEnumerable < KeyValuePair< int, T > > | Items< T > (this ISparseListSource< T > list) |
Returns the non-cleared items in the sparse list, along with their indexes, sorted by index. More... | |
static T | Pop< T > (this IPop< T > c) |
static T | Peek< T > (this IPop< T > c) |
static bool | TryPop< T > (this IPop< T > c, out T value) |
static bool | TryPeek< T > (this IPop< T > c, out T value) |
static T | TryPop< T > (this IPop< T > c) |
static T | TryPeek< T > (this IPop< T > c) |
static T | TryPop< T > (this IPop< T > c, T defaultValue) |
static T | TryPeek< T > (this IPop< T > c, T defaultValue) |
static T | PopFirst< T > (this IDeque< T > c) |
static T | PopLast< T > (this IDeque< T > c) |
static T | PeekFirst< T > (this IDeque< T > c) |
static T | PeekLast< T > (this IDeque< T > c) |
static void | Resize< T > (this IListRangeMethods< T > list, int newSize) |
|
inlinestatic |
Returns true if the collection contains any elements.
|
inlinestatic |
Uses list.TryGet(index) to find out if the specified index is valid.
|
inlinestatic |
Determines the index of a specific value.
At first, this method was a member of IListSource itself, just in case the source might have some kind of fast lookup logic (e.g. binary search) or custom comparer. However, since the item to find is an "in" argument, it would prevent IListSource from being marked covariant when I upgrade to C# 4.
|
inlinestatic |
Determines the index of a specific value.
At first, this method was a member of IListSource itself, just in case the source might have some kind of fast lookup logic (e.g. binary search) or custom comparer. However, since the item to find is an "in" argument, it would prevent IListSource from being marked covariant when I upgrade to C# 4.
|
inlinestatic |
Gets the lowest index at which a condition is true, or -1 if nowhere.
|
inlinestatic |
Returns the non-cleared items in the sparse list, along with their indexes, sorted by index.
The returned sequence should exactly match the set of indexes for which list.IsSet(Key)
returns true.
|
inlinestatic |
Gets the highest index at which a condition is true, or -1 if nowhere.
|
inlinestatic |
Gets the next higher index that is not classified as an empty space, or null if there are no non-blank higher indexes.
This extension method works by calling NextHigherItem()
.
|
inlinestatic |
Gets the next lower index that is not classified as an empty space, or null if there are no non-blank lower indexes.
This extension method works by calling NextHigherItem()
.
|
inlinestatic |
Copies the contents of an IListSource to an array.
|
inlinestatic |
Tries to get a value from the list at the specified index.
index | The index to access. Valid indexes are between Min and Max. |
value | A variable that will be changed to the retrieved value. If the index is not valid, this variable is left unmodified. |
|
inlinestatic |
Tries to get a value from the list at the specified index.
index | The index to access. Valid indexes are between Min and Max. |
defaultValue | A value to return if the index is not valid. |
|
inlinestatic |
Tries to get a value from the list at the specified index.
index | The index to access. Valid indexes are between 0 and Count-1. |
value | A variable that will be changed to the retrieved value. If the index is not valid, this variable is left unmodified. |
|
inlinestatic |
Tries to get a value from the list at the specified index.
index | The index to access. Valid indexes are between 0 and Count-1. |
defaultValue | A value to return if the index is not valid. |
|
inlinestatic |
Tries to get a value from the list at the specified index.
index | The index to access. Valid indexes are between 0 and Count-1. |