Extension methods for linq operation. More...
Static Public Member Functions | |
static IEnumerable< T > | ToAotEnumerable< T > (this IEnumerable< T > source) |
Convert to the sequence supports AOT, basically for a value type. More... | |
static string | JoinText< T > (this IEnumerable< T > source, string separator="\n") |
Join the specified sequence to a string , basically for logging. More... | |
static bool | IsExist (this object value) |
Determine if the specified object is existing, i.e., not equals null . More... | |
static IEnumerable< T > | OfExist< T > (this IEnumerable< T > source) |
Filter elements which is not null . More... | |
static IEnumerable< string > | OfText (this IEnumerable< string > source) |
Filter elements which is not null or empty string . More... | |
static IEnumerable< T > | OfMatch< T > (this IEnumerable< T > source, string pattern, Func< T, string > selector=null, RegexOptions options=RegexOptions.ExplicitCapture) |
Filter elements which matches the specified regex pattern. More... | |
static Dictionary< T, U > | ToDictionary< T, U > (this IEnumerable< IGrouping< T, U >> source) |
Create a Dictionary<TKey, TValue> from the sequence of IGrouping<TKey, TValue> . More... | |
static Dictionary< T, U > | ToDictionary< T, U > (this IEnumerable< KeyValuePair< T, U >> source) |
Create a Dictionary<TKey, TValue> from the sequence of KeyValuePair<TKey, TValue> . More... | |
static Dictionary< T, U > | KeysToDictionary< T, U > (this IEnumerable< T > source, Func< T, U > elementSelector) |
Create a Dictionary<TKey, TValue> from the sequence according to an element selector function. More... | |
static IEnumerable< T > | OrderByRandom< T > (this IEnumerable< T > source) |
Sort the elements of a sequence in random order. More... | |
static T | RandomElement< T > (this IEnumerable< T > source) |
Get the random element of a sequence, or a default value if no element. More... | |
static T | RandomByWeight< T > (this IEnumerable<(T element, float weight)> source) |
Get the random element of a sequence by the specified weight, or a default value if no valid element. More... | |
Extension methods for linq operation.
3
|
static |
Convert to the sequence supports AOT, basically for a value type.
T | The element type. |
source | The source sequence. |
|
static |
Join the specified sequence to a string
, basically for logging.
T | The element type. |
source | The source sequence. |
separator | Separator. |
string
.
|
static |
Determine if the specified object is existing, i.e., not equals null
.
value | Value. |
true
, if existing, false
otherwise.
|
static |
Filter elements which is not null
.
T | The element type. |
source | The source sequence. |
|
static |
Filter elements which is not null
or empty string
.
source | The source sequence. |
|
static |
Filter elements which matches the specified regex pattern.
T | The element type. |
source | The source sequence. |
pattern | The regex pattern. |
selector | The transform function to get the text to match. |
options | The regex options. |
|
static |
Create a Dictionary<TKey, TValue>
from the sequence of IGrouping<TKey, TValue>
.
This uses the group key paired with the first element of the group.
T | The key type. |
U | The element type. |
source | The source sequence. |
|
static |
Create a Dictionary<TKey, TValue>
from the sequence of KeyValuePair<TKey, TValue>
.
Useful for arranging a dictionary, e.g., filtering, combining, or sorting.
T | The key type. |
U | The element type. |
source | The source sequence. |
|
static |
Create a Dictionary<TKey, TValue>
from the sequence according to an element selector function.
T | The key type. |
U | The element type. |
source | The source sequence. |
elementSelector | A transform function to produce an element value from each key. |
|
static |
Sort the elements of a sequence in random order.
T | The element type. |
source | The source sequence. |
|
static |
Get the random element of a sequence, or a default value if no element.
T | The element type. |
source | The source sequence. |
|
static |
Get the random element of a sequence by the specified weight, or a default value if no valid element.
T | The element type. |
source | The source sequence paired with the weight. |