Class IListExtensions
Provides extension methods for IList that support sparse lists.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Collections
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
public static class IListExtensions
Methods
AsReadOnly<T>(IList<T>)
Declaration
public static IReadOnlyList<T> AsReadOnly<T>(this IList<T> list)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list |
Returns
Type | Description |
---|---|
IReadOnlyList<T> |
Type Parameters
Name | Description |
---|---|
T |
Inner(IList<Int32>, IList<Double>)
Computes the inner product between an integer list and a double list of the same size.
Declaration
public static double Inner(this IList<int> source, IList<double> that)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | source | |
IList<Double> | that |
Returns
Type | Description |
---|---|
Double |
IsSparse<T>(IList<T>)
Returns true if and only if this list is sparse
Declaration
public static bool IsSparse<T>(this IList<T> source)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | source | The list |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | The type of this list |
ListReduce<T, TRes>(IList<T>, TRes, Func<TRes, T, TRes>)
Reduces across a list.
Declaration
public static TRes ListReduce<T, TRes>(this IList<T> source, TRes initial, Func<TRes, T, TRes> fun)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | source | This list |
TRes | initial | Initial value for reduction |
Func<TRes, T, TRes> | fun | The function |
Returns
Type | Description |
---|---|
TRes |
Type Parameters
Name | Description |
---|---|
T | Type of this list |
TRes | Type of result |
ListReduce<T, T2, TRes>(IList<T>, IEnumerable<T2>, TRes, Func<TRes, T, T2, TRes>)
Reduces across a list and another collection
Declaration
public static TRes ListReduce<T, T2, TRes>(this IList<T> source, IEnumerable<T2> secondList, TRes initial, Func<TRes, T, T2, TRes> fun)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | source | This list |
IEnumerable<T2> | secondList | The other collection |
TRes | initial | Initial value for reduction |
Func<TRes, T, T2, TRes> | fun | The function |
Returns
Type | Description |
---|---|
TRes |
Type Parameters
Name | Description |
---|---|
T | Type of this list |
T2 | Type of the other list |
TRes | Type of result |
ListSelect<T, T2>(IList<T>, Func<T, T2>)
Similar to LINQ Select, except it takes and returns a list. If the supplied list is sparse, the returned list will also be sparse.
Declaration
public static IList<T2> ListSelect<T, T2>(this IList<T> source, Func<T, T2> converter)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | source | This list |
Func<T, T2> | converter | The converter |
Returns
Type | Description |
---|---|
IList<T2> |
Type Parameters
Name | Description |
---|---|
T | The type of this list |
T2 | The target element type |
ListSum(IList<Int32>)
Sums the elements of this list.
Declaration
public static int ListSum(this IList<int> source)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | source |
Returns
Type | Description |
---|---|
Int32 |
ListSum(IList<Int32>, Func<Int32, Double>)
Sums the elements of this list, after transforming each element using the specified converter.
Declaration
public static double ListSum(this IList<int> source, Func<int, double> converter)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | source | |
Func<Int32, Double> | converter | The converter |
Returns
Type | Description |
---|---|
Double |
SetTo(IList<Double>, IEnumerable<Double>)
Sets this list from an enumerable (need separate implementation from generic version for interop with Vectors)
Declaration
public static void SetTo(this IList<double> source, IEnumerable<double> that)
Parameters
Type | Name | Description |
---|---|---|
IList<Double> | source | |
IEnumerable<Double> | that |
SetTo<T>(IList<T>, IEnumerable<T>)
Sets this list from an enumerable
Declaration
public static void SetTo<T>(this IList<T> source, IEnumerable<T> that)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | source | |
IEnumerable<T> | that |
Type Parameters
Name | Description |
---|---|
T |
ToVector(IList<Double>)
Converts a list of doubles into a vector.
Declaration
public static Vector ToVector(this IList<double> source)
Parameters
Type | Name | Description |
---|---|---|
IList<Double> | source |
Returns
Type | Description |
---|---|
Vector |
ToVector(IList<Int32>)
Converts a list of ints into a double vector.
Declaration
public static Vector ToVector(this IList<int> source)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | source |
Returns
Type | Description |
---|---|
Vector |