Table of Contents

Class EarlyTerminatingLinqExtensions

Namespace
Garyon.Extensions
Assembly
Garyon.dll

Contains a collection of early-termiating LINQ-like extensions.

public static class EarlyTerminatingLinqExtensions
Inheritance
EarlyTerminatingLinqExtensions
Inherited Members

Methods

CutAt<T>(IEnumerable<T>, Predicate<T>, bool)

Enumerates a collection, but halts enumeration as soon as a value that satisfies the given predicate is found.

public static IEnumerable<T> CutAt<T>(this IEnumerable<T> source, Predicate<T> predicate, bool includeHaltingValue = false)

Parameters

source IEnumerable<T>

The collection whose values to enumerate and evaluate through predicate.

predicate Predicate<T>

The predicate which will cause enumeration to halt upon being satisfied.

includeHaltingValue bool

Determines whether the final value that causes enumeration to halt should be retuned or not.

Returns

IEnumerable<T>

The first elements that do not satisfy predicate, and, optionally, the first value that satisfies it.

Type Parameters

T

The type of the values the collection contains.

SumSatisfies(IEnumerable<uint>, ComparisonKinds, uint)

Determines whether the sum of a collection of values satisfies a comparison against the target value.

public static bool SumSatisfies(this IEnumerable<uint> values, ComparisonKinds comparisonKinds, uint target)

Parameters

values IEnumerable<uint>

The collection of values whose sum to calculate.

comparisonKinds ComparisonKinds

The comparison kinds that must be satisfied.

target uint

The target value to compare the collection's sum against.

Returns

bool

true if the sum satisfies the given comparison, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumSatisfies(IEnumerable<ulong>, ComparisonKinds, ulong)

Determines whether the sum of a collection of values satisfies a comparison against the target value.

public static bool SumSatisfies(this IEnumerable<ulong> values, ComparisonKinds comparisonKinds, ulong target)

Parameters

values IEnumerable<ulong>

The collection of values whose sum to calculate.

comparisonKinds ComparisonKinds

The comparison kinds that must be satisfied.

target ulong

The target value to compare the collection's sum against.

Returns

bool

true if the sum satisfies the given comparison, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsAtLeast(IEnumerable<uint>, uint)

Determines whether the sum of a collection of values is at least equal to the target.

public static bool SumsAtLeast(this IEnumerable<uint> values, uint target)

Parameters

values IEnumerable<uint>

The collection of values whose sum to calculate.

target uint

The target value to compare the collection's sum against.

Returns

bool

true if the sum is greater than or equal to (>=) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsAtLeast(IEnumerable<ulong>, ulong)

Determines whether the sum of a collection of values is at least equal to the target.

public static bool SumsAtLeast(this IEnumerable<ulong> values, ulong target)

Parameters

values IEnumerable<ulong>

The collection of values whose sum to calculate.

target ulong

The target value to compare the collection's sum against.

Returns

bool

true if the sum is greater than or equal to (>=) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsAtMost(IEnumerable<uint>, uint)

Determines whether the sum of a collection of values is at most equal to the target.

public static bool SumsAtMost(this IEnumerable<uint> values, uint target)

Parameters

values IEnumerable<uint>

The collection of values whose sum to calculate.

target uint

The target value to compare the collection's sum against.

Returns

bool

true if the sum is less than or equal to (<=) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsAtMost(IEnumerable<ulong>, ulong)

Determines whether the sum of a collection of values is at most equal to the target.

public static bool SumsAtMost(this IEnumerable<ulong> values, ulong target)

Parameters

values IEnumerable<ulong>

The collection of values whose sum to calculate.

target ulong

The target value to compare the collection's sum against.

Returns

bool

true if the sum is less than or equal to (<=) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsBelow(IEnumerable<uint>, uint)

Determines whether the sum of a collection of values is strictly less than the target.

public static bool SumsBelow(this IEnumerable<uint> values, uint target)

Parameters

values IEnumerable<uint>

The collection of values whose sum to calculate.

target uint

The target value to compare the collection's sum against.

Returns

bool

true if the sum is strictly less than (<) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsBelow(IEnumerable<ulong>, ulong)

Determines whether the sum of a collection of values is strictly less than the target.

public static bool SumsBelow(this IEnumerable<ulong> values, ulong target)

Parameters

values IEnumerable<ulong>

The collection of values whose sum to calculate.

target ulong

The target value to compare the collection's sum against.

Returns

bool

true if the sum is strictly less than (<) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsOver(IEnumerable<uint>, uint)

Determines whether the sum of a collection of values is strictly greater than the target.

public static bool SumsOver(this IEnumerable<uint> values, uint target)

Parameters

values IEnumerable<uint>

The collection of values whose sum to calculate.

target uint

The target value to compare the collection's sum against.

Returns

bool

true if the sum is strictly greater than (>) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.

SumsOver(IEnumerable<ulong>, ulong)

Determines whether the sum of a collection of values is strictly greater than the target.

public static bool SumsOver(this IEnumerable<ulong> values, ulong target)

Parameters

values IEnumerable<ulong>

The collection of values whose sum to calculate.

target ulong

The target value to compare the collection's sum against.

Returns

bool

true if the sum is strictly greater than (>) the target, otherwise false.

Remarks

It is not necessary that the entire collection is enumerated. Enumeration halts upon alternation of satisfying the given comparison.
Overflows are not accounted for. Ensure that the sum of the entire collection will not overflow, causing this result to appear wrong.