|
CollectionExtensionsMajorityByTSource, TKey(IEnumerableTSource, TSource, FuncTSource, TKey, Boolean, IEqualityComparerTKey) Method
|
Returns the majority value in the collection, or defaultValue if no item represents the majority.
Namespace: GSF.CollectionsAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.218-beta+101eee949414e414795e55a6e73d88938f0177b8
Syntax public static TSource MajorityBy<TSource, TKey>(
this IEnumerable<TSource> source,
TSource defaultValue,
Func<TSource, TKey> keySelector,
bool forwardSearch = true,
IEqualityComparer<TKey> comparer = null
)
<ExtensionAttribute>
Public Shared Function MajorityBy(Of TSource, TKey) (
source As IEnumerable(Of TSource),
defaultValue As TSource,
keySelector As Func(Of TSource, TKey),
Optional forwardSearch As Boolean = true,
Optional comparer As IEqualityComparer(Of TKey) = Nothing
) As TSource
[<ExtensionAttribute>]
static member MajorityBy :
source : IEnumerable<'TSource> *
defaultValue : 'TSource *
keySelector : Func<'TSource, 'TKey> *
?forwardSearch : bool *
?comparer : IEqualityComparer<'TKey>
(* Defaults:
let _forwardSearch = defaultArg forwardSearch true
let _comparer = defaultArg comparer null
*)
-> 'TSource
JavaScript does not support generic types or methods.
View SourceParameters
- source IEnumerableTSource
- An enumeration over which to find the majority element.
- defaultValue TSource
- Default value to return if no item represents the majority.
- keySelector FuncTSource, TKey
- A delegate that takes an object and produces the key for comparison.
- forwardSearch Boolean (Optional)
- true to search forward in source; otherwise false to search backwards.
- comparer IEqualityComparerTKey (Optional)
- The IEqualityComparerT implementation to use when comparing keys, or null to use the default comparer for the type of the key.
Type Parameters
- TSource
- Type of elements in the source.
- TKey
- The generic type of the objects to be compared.
Return Value
TSourceThe majority value in the collection.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
See Also