Class ListUtil
Inheritance
System.Object
ListUtil
Assembly: Eco.Shared.dll
Syntax
public static class ListUtil : Object
Methods
CommaListNonNull<T>(LocString[])
Declaration
public static string CommaListNonNull<T>(params LocString[] list)
Parameters
Returns
Type |
Description |
System.String |
|
Type Parameters
ConvertToBits<T>(IList<T>, Func<T, Boolean>)
Converts container into 64bit data.
Declaration
public static ulong ConvertToBits<T>(this IList<T> list, Func<T, bool> compareFunc)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
list |
|
System.Func<T, System.Boolean> |
compareFunc |
Comparer for saving the bit
|
Returns
Type |
Description |
System.UInt64 |
|
Type Parameters
Exceptions
Type |
Condition |
System.IndexOutOfRangeException |
If container size is more than 64
|
DepthFirstTraversal<T>(T, Func<T, IEnumerable<T>>)
Declaration
public static IEnumerable<(T, int)> DepthFirstTraversal<T>(this T root, Func<T, IEnumerable<T>> getChildren)
Parameters
Type |
Name |
Description |
T |
root |
|
System.Func<T, System.Collections.Generic.IEnumerable<T>> |
getChildren |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<T, System.Int32>> |
|
Type Parameters
ForEachTuple<T1, T2>(IEnumerable<T1>, IEnumerable<T2>)
For-each across two enumerables, stopping when either ends.
Declaration
public static IEnumerable<(T1, T2)> ForEachTuple<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T1> |
first |
|
System.Collections.Generic.IEnumerable<T2> |
second |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<T1, T2>> |
|
Type Parameters
GetPrevAndCurrentPairs<T>(IEnumerable<T>)
Declaration
public static IEnumerable<(T, T)> GetPrevAndCurrentPairs<T>(this IEnumerable<T> list)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<T, T>> |
|
Type Parameters
IsSortedAscending<T>(IEnumerable<T>)
Declaration
public static bool IsSortedAscending<T>(this IEnumerable<T> list)
where T : IComparable
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
List<T>(T[])
Declaration
public static IEnumerable<T> List<T>(params T[] list)
Parameters
Type |
Name |
Description |
T[] |
list |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<T> |
|
Type Parameters
NonNull<T>(T[])
Declaration
public static IEnumerable<T> NonNull<T>(params T[] list)
Parameters
Type |
Name |
Description |
T[] |
list |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<T> |
|
Type Parameters
OneOrNull<T>(IEnumerable<T>)
Declaration
public static T OneOrNull<T>(this IEnumerable<T> list)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
Returns
Type Parameters
TakeAndCalculateForRest<T>(IEnumerable<T>, Int32, Func<T, Int32>)
Take First numToTake of items in IEnumerable and apply function doForRest on the elements left in IEnumerable.
Declaration
public static List<T> TakeAndCalculateForRest<T>(this IEnumerable<T> list, int numToTake, Func<T, int> doForRest)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
System.Int32 |
numToTake |
|
System.Func<T, System.Int32> |
doForRest |
|
Returns
Type |
Description |
System.Collections.Generic.List<T> |
|
Type Parameters
TakeSame<TEntry, TVal>(IEnumerable<TEntry>, Func<TEntry, TVal>)
Declaration
public static IEnumerable<TEntry> TakeSame<TEntry, TVal>(this IEnumerable<TEntry> list, Func<TEntry, TVal> testSame)
where TVal : IComparable
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<TEntry> |
list |
|
System.Func<TEntry, TVal> |
testSame |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<TEntry> |
|
Type Parameters
Name |
Description |
TEntry |
|
TVal |
|
TakeSelectAndCalcRest<T, TResult>(IEnumerable<T>, Int32, Func<T, TResult>, Func<T, Int32>)
Take first numToTake
of items in IEnumerable, transform it with Func doWithTaken
and apply Func doForRest
on the elements left in IEnumerable.
Declaration
public static List<TResult> TakeSelectAndCalcRest<T, TResult>(this IEnumerable<T> list, int numToTake, Func<T, TResult> doWithTaken, Func<T, int> doForRest)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
System.Int32 |
numToTake |
|
System.Func<T, TResult> |
doWithTaken |
|
System.Func<T, System.Int32> |
doForRest |
|
Returns
Type |
Description |
System.Collections.Generic.List<TResult> |
|
Type Parameters
Name |
Description |
T |
|
TResult |
|