Class List
Provides various extensions for
Namespace: DotNext.Collections.Generic
Assembly: DotNext.dll
Syntax
public static class List : object
Methods
| Improve this Doc View SourceConvert<I, O>(IReadOnlyList<I>, Converter<I, O>)
Returns lazily converted read-only list.
Declaration
public static ReadOnlyListView<I, O> Convert<I, O>(this IReadOnlyList<I> list, Converter<I, O> converter)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<I> | list | Read-only list to convert. |
DotNext.Converter<I, O> | converter | A list item conversion function. |
Returns
Type | Description |
---|---|
ReadOnlyListView<I, O> | Lazily converted read-only list. |
Type Parameters
Name | Description |
---|---|
I | Type of items in the source list. |
O | Type of items in the target list. |
Convert<I, O>(IReadOnlyList<I>, ValueFunc<I, O>)
Returns lazily converted read-only list.
Declaration
public static ReadOnlyListView<I, O> Convert<I, O>(this IReadOnlyList<I> list, in ValueFunc<I, O> converter)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<I> | list | Read-only list to convert. |
ValueFunc<I, O> | converter | A list item conversion function. |
Returns
Type | Description |
---|---|
ReadOnlyListView<I, O> | Lazily converted read-only list. |
Type Parameters
Name | Description |
---|---|
I | Type of items in the source list. |
O | Type of items in the target list. |
IndexerGetter<T>(IList<T>)
Returns
Declaration
public static Func<int, T> IndexerGetter<T>(this IList<T> list)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | Mutable list instance. |
Returns
Type | Description |
---|---|
DotNext.Func<Int32, T> | A delegate representing indexer. |
Type Parameters
Name | Description |
---|---|
T | Type of list items. |
IndexerGetter<T>(IReadOnlyList<T>)
Returns
Declaration
public static Func<int, T> IndexerGetter<T>(this IReadOnlyList<T> list)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<T> | list | Read-only list instance. |
Returns
Type | Description |
---|---|
DotNext.Func<Int32, T> | A delegate representing indexer. |
Type Parameters
Name | Description |
---|---|
T | Type of list items. |
IndexerSetter<T>(IList<T>)
Returns
Declaration
public static Action<int, T> IndexerSetter<T>(this IList<T> list)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | Mutable list instance. |
Returns
Type | Description |
---|---|
Action<Int32, T> | A delegate representing indexer. |
Type Parameters
Name | Description |
---|---|
T | Type of list items. |
InsertOrdered<T>(IList<T>, T, Comparison<T>)
Inserts the item into sorted list.
Declaration
public static int InsertOrdered<T>(this IList<T> list, T item, Comparison<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The list to insert into. |
T | item | The item to be added into the list. |
DotNext.Comparison<T> | comparer | The comparer function. |
Returns
Type | Description |
---|---|
Int32 | The actual index of the inserted item. |
Type Parameters
Name | Description |
---|---|
T | The type of the items in the list. |
Remarks
Time complexity of this operation is O(log N), where N is a size of the list.
InsertOrdered<T>(IList<T>, T, ValueFunc<T, T, Int32>)
Inserts the item into sorted list.
Declaration
public static int InsertOrdered<T>(this IList<T> list, T item, in ValueFunc<T, T, int> comparer)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The list to insert into. |
T | item | The item to be added into the list. |
ValueFunc<T, T, Int32> | comparer | The comparer function. |
Returns
Type | Description |
---|---|
Int32 | The actual index of the inserted item. |
Type Parameters
Name | Description |
---|---|
T | The type of the items in the list. |
Remarks
Time complexity of this operation is O(log N), where N is a size of the list.
Singleton<T>(T)
Constructs read-only list with single item in it.
Declaration
public static IReadOnlyList<T> Singleton<T>(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | An item to be placed into list. |
Returns
Type | Description |
---|---|
IReadOnlyList<T> | Read-only list containing single item. |
Type Parameters
Name | Description |
---|---|
T | Type of list items. |
ToArray<I, O>(IList<I>, Converter<I, O>)
Converts list into array and perform mapping for each element.
Declaration
public static O[] ToArray<I, O>(this IList<I> input, Converter<I, O> mapper)
Parameters
Type | Name | Description |
---|---|---|
IList<I> | input | A list to convert. Cannot be null. |
DotNext.Converter<I, O> | mapper | Element mapping function. |
Returns
Type | Description |
---|---|
O[] | An array of list items. |
Type Parameters
Name | Description |
---|---|
I | Type of elements in the list. |
O | Type of elements in the output array. |
ToArray<I, O>(IList<I>, Func<Int32, I, O>)
Converts list into array and perform mapping for each element.
Declaration
public static O[] ToArray<I, O>(this IList<I> input, Func<int, I, O> mapper)
Parameters
Type | Name | Description |
---|---|---|
IList<I> | input | A list to convert. Cannot be null. |
DotNext.Func<Int32, I, O> | mapper | Index-aware element mapping function. |
Returns
Type | Description |
---|---|
O[] | An array of list items. |
Type Parameters
Name | Description |
---|---|
I | Type of elements in the list. |
O | Type of elements in the output array. |
ToArray<I, O>(IList<I>, ValueFunc<I, O>)
Converts list into array and perform mapping for each element.
Declaration
public static O[] ToArray<I, O>(this IList<I> input, in ValueFunc<I, O> mapper)
Parameters
Type | Name | Description |
---|---|---|
IList<I> | input | A list to convert. Cannot be null. |
ValueFunc<I, O> | mapper | Element mapping function. |
Returns
Type | Description |
---|---|
O[] | An array of list items. |
Type Parameters
Name | Description |
---|---|
I | Type of elements in the list. |
O | Type of elements in the output array. |
ToArray<I, O>(IList<I>, ValueFunc<Int32, I, O>)
Converts list into array and perform mapping for each element.
Declaration
public static O[] ToArray<I, O>(this IList<I> input, in ValueFunc<int, I, O> mapper)
Parameters
Type | Name | Description |
---|---|---|
IList<I> | input | A list to convert. Cannot be null. |
ValueFunc<Int32, I, O> | mapper | Index-aware element mapping function. |
Returns
Type | Description |
---|---|
O[] | An array of list items. |
Type Parameters
Name | Description |
---|---|
I | Type of elements in the list. |
O | Type of elements in the output array. |