Class BetternessExtensions
Extension methods related to the BetterResult enum.
Inheritance
Inherited Members
Namespace: Flame.Collections
Assembly: Flame.dll
Syntax
public static class BetternessExtensions
Methods
| Improve this Doc View SourceFlip(Betterness)
"Flips" the given betterness: if the first element was better, then this method returns a betterness for the second element, and vice-versa.
Declaration
public static Betterness Flip(this Betterness Value)
Parameters
Type | Name | Description |
---|---|---|
Betterness | Value | The beterness to flip. |
Returns
Type | Description |
---|---|
Betterness |
GetBestElementOrDefault<T>(IEnumerable<T>, Func<T, T, Betterness>)
Tries the get best element in the sequence: the element that is better than every other element. If no such elemet is found, then the default value for its type is returned.
Declaration
public static T GetBestElementOrDefault<T>(this IEnumerable<T> Elements, Func<T, T, Betterness> Compare)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | Elements | The sequence of elements to search through. |
System.Func<T, T, Betterness> | Compare | A function that compares to elements for betterness. |
Returns
Type | Description |
---|---|
T | The best element or the default value for its type. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the sequence. |
TryGetBestElement<T>(IEnumerable<T>, Func<T, T, Betterness>, out T)
Tries the get best element in the sequence: the element that is better than every other element.
Declaration
public static bool TryGetBestElement<T>(this IEnumerable<T> Elements, Func<T, T, Betterness> Compare, out T BestElement)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | Elements | The sequence of elements to search through. |
System.Func<T, T, Betterness> | Compare | A function that compares to elements for betterness. |
T | BestElement | The best element in the sequence. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of elements in the sequence. |