 | CondensedCollectionExtensionsSumTSource Method (CondensedCollectionTSource, FuncTSource, Int32) |
[This is preliminary documentation and is subject to change.]
Computes the sum of a CondensedCollection of Int32 values that are obtained by invoking a transform
function on each element of the input sequence. Optimized for a CondensedCollection.
Namespace:
Condensed.Linq
Assembly:
Condensed (in Condensed.dll) Version: 0.1.0.0 (0.1.0.0)
Syntaxpublic static int Sum<TSource>(
this CondensedCollection<TSource> source,
Func<TSource, int> selector
)
<ExtensionAttribute>
Public Shared Function Sum(Of TSource) (
source As CondensedCollection(Of TSource),
selector As Func(Of TSource, Integer)
) As Integer
public:
[ExtensionAttribute]
generic<typename TSource>
static int Sum(
CondensedCollection<TSource>^ source,
Func<TSource, int>^ selector
)
[<ExtensionAttribute>]
static member Sum :
source : CondensedCollection<'TSource> *
selector : Func<'TSource, int> -> int
Parameters
- source
- Type: CondensedCondensedCollectionTSource
A CondensedCollection of values to calculate the sum of. - selector
- Type: SystemFuncTSource, Int32
A transform function to apply to each element.
Type Parameters
- TSource
- The type of the elements of source.
Return Value
Type:
Int32The sum of the sequence of values.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
CondensedCollectionTSource. 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).
Exceptions
Remarks
This implementation of Sum() is specialized for a CondensedCollection and tries to
take advantage of the CondensedCollection's knowledge of unique values in order to improve performance.
If you would rather use the normal LINQ extension method then cast the CondensedCollection to an
IListT
to use the
SumTSource(IEnumerableTSource, FuncTSource, Int32) implementation.
See Also