Cadenza : Cadenza.Collections Namespace

EnumerableCoda Class

Extension methods on IEnumerable<T>.

public static class EnumerableCoda

Thread Safety

This type is thread safe.

Remarks

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Members

See Also: Inherited members from object.

Public Methods

static
AggregateHistory<TSource> (this IEnumerable<TSource>, Func<TSource, TSource, TSource>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
AggregateHistory<TSource,TAccumulate> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>) : IEnumerable<TAccumulate>
Documentation for this section has not yet been entered.
static
AggregateHistory<TSource,TAccumulate,TResult> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, Func<TAccumulate, TResult>) : IEnumerable<TResult>
Documentation for this section has not yet been entered.
static
AggregateReverse<TSource> (this IEnumerable<TSource>, Func<TSource, TSource, TSource>) : TSource
Documentation for this section has not yet been entered.
static
AggregateReverse<TSource,TAccumulate> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>) : TAccumulate
Documentation for this section has not yet been entered.
static
AggregateReverse<TSource,TAccumulate,TResult> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, Func<TAccumulate, TResult>) : TResult
Documentation for this section has not yet been entered.
static
AggregateReverseHistory<TSource> (this IEnumerable<TSource>, Func<TSource, TSource, TSource>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
AggregateReverseHistory<TSource,TAccumulate> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>) : IEnumerable<TAccumulate>
Documentation for this section has not yet been entered.
static
AggregateReverseHistory<TSource,TAccumulate,TResult> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, Func<TAccumulate, TResult>) : IEnumerable<TResult>
Documentation for this section has not yet been entered.
static
And (this IEnumerable<bool>) : bool
Documentation for this section has not yet been entered.
static
Apply<TSource> (this IEnumerable<TSource>)
Documentation for this section has not yet been entered.
static
ApplyPairs<TSource> (this IEnumerable<TSource>, params Action<TSource>[]) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
AsIList<TSource> (this IEnumerable<TSource>) : IList<TSource>
Documentation for this section has not yet been entered.
static
Break<TSource> (this IEnumerable<TSource>, Func<TSource, bool>) : Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>
Documentation for this section has not yet been entered.
static
Cache<T> (this IEnumerable<T>) : CachedSequence<T>
Documentation for this section has not yet been entered.
static
CompareWith<T> (this IEnumerable<T>, IEnumerable<T>) : SequenceComparison<T>
Compares two enumerations retrieving added, removed and unchanged elements.
static
CompareWith<T> (this IEnumerable<T>, IEnumerable<T>, IEqualityComparer<T>) : SequenceComparison<T>
Compares two enumerations retrieving added, removed and unchanged elements.
static
Concat<TSource> (this IEnumerable<TSource>, IEnumerable<IEnumerable<TSource>>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Concat<TSource> (this IEnumerable<TSource>, params IEnumerable<TSource>[]) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
ContiguousSubsequences<TSource> (this IEnumerable<TSource>, int) : IEnumerable<IEnumerable<TSource>>
Documentation for this section has not yet been entered.
static
CopyTo<TSource> (this IEnumerable<TSource>, ICollection<TSource>)
Documentation for this section has not yet been entered.
static
CopyTo<TSource> (this IEnumerable<TSource>, TSource[], int)
Documentation for this section has not yet been entered.
static
Cycle<TSource> (this IEnumerable<TSource>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Each<TSource> (this IEnumerable<TSource>, Action<TSource, int>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Each<TSource> (this IEnumerable<TSource>, Action<TSource>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
ExceptLast<TSource> (this IEnumerable<TSource>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
ExceptLast<TSource> (this IEnumerable<TSource>, int) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
FindIndex<TSource> (this IEnumerable<TSource>, Func<TSource, bool>) : int
Documentation for this section has not yet been entered.
static
FindIndices<TSource> (this IEnumerable<TSource>, Func<TSource, bool>) : IEnumerable<int>
Documentation for this section has not yet been entered.
static
ForEach<TSource> (this IEnumerable<TSource>, Action<TSource, int>)
Documentation for this section has not yet been entered.
static
ForEach<TSource> (this IEnumerable<TSource>, Action<TSource>)
Documentation for this section has not yet been entered.
static
HaskellGroup<TSource> (this IEnumerable<TSource>) : IEnumerable<IEnumerable<TSource>>
Documentation for this section has not yet been entered.
static
HaskellGroupBy<TSource> (this IEnumerable<TSource>, Func<TSource, TSource, bool>) : IEnumerable<IEnumerable<TSource>>
Split self into a sequence of groups.
static
Implode<TSource> (this IEnumerable<TSource>) : string
Documentation for this section has not yet been entered.
static
Implode<TSource> (this IEnumerable<TSource>, string) : string
Documentation for this section has not yet been entered.
static
Implode<TSource> (this IEnumerable<TSource>, string, Func<TSource, string>) : string
Documentation for this section has not yet been entered.
static
IndexOf<TSource> (this IEnumerable<TSource>, TSource) : int
Documentation for this section has not yet been entered.
static
IndexOfAny<TSource> (this IEnumerable<TSource>, IEnumerable<TSource>) : int
Documentation for this section has not yet been entered.
static
IndexOfAny<TSource> (this IEnumerable<TSource>, params TSource[]) : int
Documentation for this section has not yet been entered.
static
IndicesOf<TSource> (this IEnumerable<TSource>, TSource) : IEnumerable<int>
Documentation for this section has not yet been entered.
static
IndicesOfAny<TSource> (this IEnumerable<TSource>, IEnumerable<TSource>) : IEnumerable<int>
Documentation for this section has not yet been entered.
static
IndicesOfAny<TSource> (this IEnumerable<TSource>, params TSource[]) : IEnumerable<int>
Documentation for this section has not yet been entered.
static
InitialSegments<TSource> (this IEnumerable<TSource>) : IEnumerable<IEnumerable<TSource>>
Creates a IEnumerable<IEnumerable<TSource>> containing all leading segments of self, shortest first.
static
Insert<TSource> (this IEnumerable<TSource>, TSource) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Insert<TSource> (this IEnumerable<TSource>, TSource, Func<TSource, TSource, int>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Intersperse<TSource> (this IEnumerable<IEnumerable<TSource>>, IEnumerable<TSource>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Intersperse<TSource> (this IEnumerable<TSource>, TSource) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
NotNull<TSource> (this IEnumerable<Nullable<TSource>>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Or (this IEnumerable<bool>) : bool
Documentation for this section has not yet been entered.
static
OrderByNatural<TSource> (this IEnumerable<TSource>, Func<TSource, string>) : IEnumerable<TSource>
Documentation for this section has not yet been entered.
static
Partition<TSource> (this IEnumerable<TSource>, Func<TSource, bool>) : Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>
Partitions self into two sequences, those which contain elements satisfying predicate and those which do not.
static
PathCombine (this IEnumerable<string>) : string
Creates a path string by concatenating the elements of self.
static
RemoveFirstOccurrence<TSource> (this IEnumerable<TSource>, TSource) : IEnumerable<TSource>
Removes the first occurrence of value from the sequence self.
static
RemoveFirstOccurrence<TSource> (this IEnumerable<TSource>, TSource, IEqualityComparer<TSource>) : IEnumerable<TSource>
Removes the first occurrence of value from the sequence self.
static
RemoveFirstOccurrences<TSource> (this IEnumerable<TSource>, TSource, int) : IEnumerable<TSource>
Removes the first count occurrences of value from the sequence self.
static
RemoveFirstOccurrences<TSource> (this IEnumerable<TSource>, TSource, int, IEqualityComparer<TSource>) : IEnumerable<TSource>
Removes the first count occurrences of value from the sequence self.
static
Repeat<TSource> (this IEnumerable<TSource>, int) : IEnumerable<TSource>
Repeats the sequence self for number repetitions.
static
SelectAggregated<TSource,TAccumulate,TResult> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, Cadenza.Tuple<TAccumulate, TResult>>) : Cadenza.Tuple<TAccumulate, List<TResult>>
Applies func to each element within self, returning the final value of the accumulator and the list of intermediate values.
static
SelectBreadthFirst<TSource,TResult> (this IEnumerable<TSource>, Func<TSource, TResult>, Func<TSource, IEnumerable<TSource>>) : IEnumerable<TResult>
Traverse a sequence of nodes in a breadth-first fashion, converting each encountered node.
static
SelectDepthFirst<TSource,TResult> (this IEnumerable<TSource>, Func<TSource, TResult>, Func<TSource, IEnumerable<TSource>>) : IEnumerable<TResult>
Traverse a sequence of nodes in a depth-first fashion, converting each encountered node.
static
SelectFromEach<T1,T2,TResult> (this IEnumerable<T1>, IEnumerable<T2>, Func<T1, T2, TResult>) : IEnumerable<TResult>
Projects each corresponding element from multiple sequences into a new form.
static
SelectFromEach<T1,T2,T3,TResult> (this IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, Func<T1, T2, T3, TResult>) : IEnumerable<TResult>
Projects each corresponding element from multiple sequences into a new form.
static
SelectFromEach<T1,T2,T3,T4,TResult> (this IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>, Func<T1, T2, T3, T4, TResult>) : IEnumerable<TResult>
Projects each corresponding element from multiple sequences into a new form.
static
SelectReverseAggregated<TSource,TAccumulate,TResult> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, Cadenza.Tuple<TAccumulate, TResult>>) : Cadenza.Tuple<TAccumulate, List<TResult>>
Applies func to each element within self in reverse order, returning the final value of the accumulator and the list of intermediate values.
static
SequenceCompare<TSource> (this IEnumerable<TSource>, IEnumerable<TSource>) : int
Compares the elements of two sequences by using the default comparer for their type.
static
SequenceCompare<TSource> (this IEnumerable<TSource>, IEnumerable<TSource>, IComparer<TSource>) : int
Compares the elements of two sequences by using a specified IComparer<TSource>.
static
Shuffle<TSource> (this IEnumerable<TSource>) : IEnumerable<TSource>
Randomizes the ordering of items within self.
static
Shuffle<TSource> (this IEnumerable<TSource>, Random) : IEnumerable<TSource>
Randomizes the ordering of items within self.
static
SkipPrefix<TSource> (this IEnumerable<TSource>, IEnumerable<TSource>) : IEnumerable<TSource>
Skips over prefix, returning the elements following prefix.
static
SkipPrefix<TSource> (this IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) : IEnumerable<TSource>
Skips over prefix, returning the elements following prefix.
static
Sort<TSource> (this IEnumerable<TSource>) : IEnumerable<TSource>
Sorts the elements in the sequence self using the default comparer.
static
Sort<TSource> (this IEnumerable<TSource>, IComparer<TSource>) : IEnumerable<TSource>
Sorts the elements in the sequence self using the specified comparer.
static
Sort<TSource> (this IEnumerable<TSource>, Comparison<TSource>) : IEnumerable<TSource>
Sorts the elements in the sequence self using the specified comparer.
static
SortNatural (this IEnumerable<string>) : IEnumerable<string>
Returns a new IEnumerable<TSource> which contains the elements within self sorted using the Cadenza.NaturalStringComparer.Default comparer.
static
Span<TSource> (this IEnumerable<TSource>, Func<TSource, bool>) : Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>
Creates a Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>> of the contiguous elements at the start of self which satisfy predicate.
static
SplitAt<TSource> (this IEnumerable<TSource>, int) : Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>
Splits self at firstLength, creating a Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>.
static
Subsets<TSource> (this IEnumerable<TSource>) : IEnumerable<IEnumerable<TSource>>
Creates all subsets of a given input sequence.
static
Subsets<TSource> (this IEnumerable<TSource>, Func<IEnumerable<TSource>,System.Boolean>) : IEnumerable<IEnumerable<TSource>>
Creates all subsets that match predicate.
static
Tokens<TSource,TAccumulate,TResult> (this IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, Func<TAccumulate, Cadenza.Tuple<TResult, TAccumulate>>, params Func<TAccumulate, TSource, bool>[]) : IEnumerable<TResult>
A simple lexer to convert an IEnumerable<TSource> into a IEnumerable<TResult>, where the resulting sequence may have a different number of elements than the source sequence.
static
ToList<TSource> (this IEnumerable<IEnumerable<TSource>>) : List<List<TSource>>
Creates a List<List<TSource>> with the same ordering and values as self.
static
ToReadOnlyDictionary<TSource,TKey> (this IEnumerable<TSource>, Func<TSource, TKey>) : ReadOnlyDictionary<TKey, TSource>
Creates a Cadenza.Collections.ReadOnlyDictionary<TKey, TSource> from an IEnumerable<TSource> according to a specified key selector and value selector delegate.
static
ToReadOnlyDictionary<TSource,TKey,TValue> (this IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TValue>) : ReadOnlyDictionary<TKey, TValue>
Creates a Cadenza.Collections.ReadOnlyDictionary<TKey, TValue> from an IEnumerable<TSource> according to a specified key selector and value selector delegate.
static
ToTuple (this IEnumerable) : object
Creates a Tuple from a sequence.
static
ToValueReader (this IEnumerable<string>) : Cadenza.IO.TextValueReader
Creates a Cadenza.IO.TextValueReader which will extract values from an IEnumerable<string>.
static
ToValueReader<TSource> (this IEnumerable<TSource>) : Cadenza.IO.EnumerableValueReader<TSource>
Creates a Cadenza.IO.EnumerableValueReader which will extract values from an IEnumerable<TSource>.
static
TrailingSegments<TSource> (this IEnumerable<TSource>) : IEnumerable<IEnumerable<TSource>>
Creates a IEnumerable<IEnumerable<TSource>> containing all final segments of self, longest first.
static
Transpose<TSource> (this IEnumerable<IEnumerable<TSource>>) : IEnumerable<IEnumerable<TSource>>
Transposes self, so that rows become columns and columns become rows in the returned IEnumerable<IEnumerable<TSource>>.
static
TryGetFirst<TSource> (this IEnumerable<TSource>, out TSource) : bool
Attempts to obtain the first element in the sequence.
static
TryGetFirst<TSource> (this IEnumerable<TSource>, Func<TSource, bool>, out TSource) : bool
Attempts to obtain the first element in the sequence that satisfies the specified condition.
static
Unzip<T1,T2> (this IEnumerable<Cadenza.Tuple<T1, T2>>) : Cadenza.Tuple<IEnumerable<T1>, IEnumerable<T2>>
Converts an IEnumerable<Cadenza.Tuple<T1, T2>> into a tuple of lists, one for each Cadenza.Tuple<T1, T2> element.
static
Unzip<T1,T2,T3> (this IEnumerable<Cadenza.Tuple<T1, T2, T3>>) : Cadenza.Tuple<IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>>
Converts an IEnumerable<Cadenza.Tuple<T1, T2, T3>> into a tuple of lists, one for each Cadenza.Tuple<T1, T2, T3> element.
static
Unzip<T1,T2,T3,T4> (this IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>>) : Cadenza.Tuple<IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>>
Converts an IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>> into a tuple of lists, one for each Cadenza.Tuple<T1, T2, T3, T4> element.
static
Zip<T1,T2> (this IEnumerable<T1>, IEnumerable<T2>) : IEnumerable<Cadenza.Tuple<T1, T2>>
Creates and returns an IEnumerable<Cadenza.Tuple<T1, T2>> containing the corresponding items from self and source2.
static
Zip<T1,T2,T3> (this IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>) : IEnumerable<Cadenza.Tuple<T1, T2, T3>>
Creates and returns an IEnumerable<Cadenza.Tuple<T1, T2, T3>> containing the corresponding items from self, source2, and source3.
static
Zip<T1,T2,T3,T4> (this IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>) : IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>>
Creates and returns an IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>> containing the corresponding items from self, source2, source3, and source4.

Member Details

AggregateHistory<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> AggregateHistory<TSource> (this IEnumerable<TSource> self, Func<TSource, TSource, TSource> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateHistory<TSource,TAccumulate> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TAccumulate> AggregateHistory<TSource, TAccumulate> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.
TAccumulate
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
seed
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateHistory<TSource,TAccumulate,TResult> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TResult> AggregateHistory<TSource, TAccumulate, TResult> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)

Type Parameters

TSource
Documentation for this section has not yet been entered.
TAccumulate
Documentation for this section has not yet been entered.
TResult
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
seed
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.
resultSelector
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateReverse<TSource> Generic Method

Documentation for this section has not yet been entered.

public static TSource AggregateReverse<TSource> (this IEnumerable<TSource> self, Func<TSource, TSource, TSource> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.
InvalidOperationException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateReverse<TSource,TAccumulate> Generic Method

Documentation for this section has not yet been entered.

public static TAccumulate AggregateReverse<TSource, TAccumulate> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.
TAccumulate
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
seed
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateReverse<TSource,TAccumulate,TResult> Generic Method

Documentation for this section has not yet been entered.

public static TResult AggregateReverse<TSource, TAccumulate, TResult> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)

Type Parameters

TSource
Documentation for this section has not yet been entered.
TAccumulate
Documentation for this section has not yet been entered.
TResult
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
seed
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.
resultSelector
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateReverseHistory<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> AggregateReverseHistory<TSource> (this IEnumerable<TSource> self, Func<TSource, TSource, TSource> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateReverseHistory<TSource,TAccumulate> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TAccumulate> AggregateReverseHistory<TSource, TAccumulate> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.
TAccumulate
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
seed
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AggregateReverseHistory<TSource,TAccumulate,TResult> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TResult> AggregateReverseHistory<TSource, TAccumulate, TResult> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)

Type Parameters

TSource
Documentation for this section has not yet been entered.
TAccumulate
Documentation for this section has not yet been entered.
TResult
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
seed
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.
resultSelector
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

And Method

Documentation for this section has not yet been entered.

public static bool And (this IEnumerable<bool> self)

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Apply<TSource> Generic Method

Documentation for this section has not yet been entered.

public static void Apply<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ApplyPairs<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> ApplyPairs<TSource> (this IEnumerable<TSource> self, params Action<TSource>[] actions)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
actions
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

AsIList<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IList<TSource> AsIList<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Break<TSource> Generic Method

Documentation for this section has not yet been entered.

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Cache<T> Generic Method

Documentation for this section has not yet been entered.

public static CachedSequence<T> Cache<T> (this IEnumerable<T> self)

Type Parameters

T
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

CompareWith<T> Generic Method

Compares two enumerations retrieving added, removed and unchanged elements.

public static SequenceComparison<T> CompareWith<T> (this IEnumerable<T> self, IEnumerable<T> update)

Type Parameters

T
The type of the elements within self and update

Parameters

self
The original enumeration of elements.
update
The updated enumeration of elements to compare against.

Returns

An Cadenza.Collections.SequenceComparison<T> containing the added, removed and unchanged elements.

Exceptions

Type Reason
ArgumentNullException update is null.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

CompareWith<T> Generic Method

Compares two enumerations retrieving added, removed and unchanged elements.

public static SequenceComparison<T> CompareWith<T> (this IEnumerable<T> self, IEnumerable<T> update, IEqualityComparer<T> comparer)

Type Parameters

T
The type of the elements within self and update

Parameters

self
The original enumeration of elements.
update
The updated enumeration of elements to compare against.
comparer
The stem.Collections.Generic.IEqualityComparer<T> used to compare equality.

Returns

An Cadenza.Collections.SequenceComparison<T> containing the added, removed and unchanged elements.

Exceptions

Type Reason
ArgumentNullException update is null.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Concat<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Concat<TSource> (this IEnumerable<TSource> self, IEnumerable<IEnumerable<TSource>> selfs)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
selfs
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Concat<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Concat<TSource> (this IEnumerable<TSource> self, params IEnumerable<TSource>[] selfs)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
selfs
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ContiguousSubsequences<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<IEnumerable<TSource>> ContiguousSubsequences<TSource> (this IEnumerable<TSource> self, int windowSize)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
windowSize
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

CopyTo<TSource> Generic Method

Documentation for this section has not yet been entered.

public static void CopyTo<TSource> (this IEnumerable<TSource> self, ICollection<TSource> destination)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
destination
Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

CopyTo<TSource> Generic Method

Documentation for this section has not yet been entered.

public static void CopyTo<TSource> (this IEnumerable<TSource> self, TSource[] array, int arrayIndex)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
array
Documentation for this section has not yet been entered.
arrayIndex
Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.
ArgumentOutOfRangeException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Cycle<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Cycle<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Each<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Each<TSource> (this IEnumerable<TSource> self, Action<TSource, int> action)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
action
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Each<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Each<TSource> (this IEnumerable<TSource> self, Action<TSource> action)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
action
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ExceptLast<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> ExceptLast<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentException Documentation for this section has not yet been entered.
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ExceptLast<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> ExceptLast<TSource> (this IEnumerable<TSource> self, int count)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
count
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentException Documentation for this section has not yet been entered.
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

FindIndex<TSource> Generic Method

Documentation for this section has not yet been entered.

public static int FindIndex<TSource> (this IEnumerable<TSource> self, Func<TSource, bool> predicate)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
predicate
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

FindIndices<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<int> FindIndices<TSource> (this IEnumerable<TSource> self, Func<TSource, bool> predicate)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
predicate
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ForEach<TSource> Generic Method

Documentation for this section has not yet been entered.

public static void ForEach<TSource> (this IEnumerable<TSource> self, Action<TSource, int> action)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
action
Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ForEach<TSource> Generic Method

Documentation for this section has not yet been entered.

public static void ForEach<TSource> (this IEnumerable<TSource> self, Action<TSource> action)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
action
Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

HaskellGroup<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<IEnumerable<TSource>> HaskellGroup<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

HaskellGroupBy<TSource> Generic Method

Split self into a sequence of groups.

public static IEnumerable<IEnumerable<TSource>> HaskellGroupBy<TSource> (this IEnumerable<TSource> self, Func<TSource, TSource, bool> func)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the elements to turn into groups.
func
A Func<TSource, TSource, bool> which is used to determine whether the TSource elements belong to the same group.

Returns

An IEnumerable<IEnumerable<TSource>> of groups.

Exceptions

Type Reason
ArgumentNullException self or func is null.

Remarks

A group is a continguence sequence of elements from self for which func(firstItemInTheGroup, currentItemInTheGroup) returns true. Once func returns false, a new group is created (and the next element within self is the first element of the new group).

C# Example
// Split a string into pairs
string s = "123456789";
int c = 0;
List<List<char>> pairs = s.HaskellGroupBy(delegate {
	++c;
	if (c < 2)
		return true;
	c = 0;
	return false;
}).ToList();
Assert.AreEqual(5, pairs.Count);
Assert.IsTrue(new[]{'1', '2'}.SequenceEqual (pairs [0]));
Assert.IsTrue(new[]{'3', '4'}.SequenceEqual (pairs [1]));
Assert.IsTrue(new[]{'5', '6'}.SequenceEqual (pairs [2]));
Assert.IsTrue(new[]{'7', '8'}.SequenceEqual (pairs [3]));
Assert.IsTrue(new[]{'9'}.SequenceEqual (pairs [4]));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Implode<TSource> Generic Method

Documentation for this section has not yet been entered.

public static string Implode<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Implode<TSource> Generic Method

Documentation for this section has not yet been entered.

public static string Implode<TSource> (this IEnumerable<TSource> self, string separator)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
separator
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Implode<TSource> Generic Method

Documentation for this section has not yet been entered.

public static string Implode<TSource> (this IEnumerable<TSource> self, string separator, Func<TSource, string> selector)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
separator
Documentation for this section has not yet been entered.
selector
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IndexOf<TSource> Generic Method

Documentation for this section has not yet been entered.

public static int IndexOf<TSource> (this IEnumerable<TSource> self, TSource value)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
value
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IndexOfAny<TSource> Generic Method

Documentation for this section has not yet been entered.

public static int IndexOfAny<TSource> (this IEnumerable<TSource> self, IEnumerable<TSource> values)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
values
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IndexOfAny<TSource> Generic Method

Documentation for this section has not yet been entered.

public static int IndexOfAny<TSource> (this IEnumerable<TSource> self, params TSource[] values)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
values
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IndicesOf<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<int> IndicesOf<TSource> (this IEnumerable<TSource> self, TSource value)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
value
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IndicesOfAny<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<int> IndicesOfAny<TSource> (this IEnumerable<TSource> self, IEnumerable<TSource> values)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
values
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IndicesOfAny<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<int> IndicesOfAny<TSource> (this IEnumerable<TSource> self, params TSource[] values)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
values
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

InitialSegments<TSource> Generic Method

Creates a IEnumerable<IEnumerable<TSource>> containing all leading segments of self, shortest first.

public static IEnumerable<IEnumerable<TSource>> InitialSegments<TSource> (this IEnumerable<TSource> self)

See Also

EnumerableCoda.TrailingSegments``1(IEnumerable<``0>)

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<TSource> containing the sequence for which to return the initial segments.

Returns

A IEnumerable<IEnumerable<TSource>> containing all leading segments of self, shortest first.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

A "leading segment" is the list of TSource values preceding the "current" index, in which the current index starts at the start of self and increments until the end of self.

C# Example
IEnumerable<IEnumerable<char>> e = "abc".InitialSegments ();
var l = e.ToList ();
Assert.AreEqual (4, l.Count);
AssertAreSame (new char[]{},          l [0]);
AssertAreSame (new[]{'a'},            l [1]);
AssertAreSame (new[]{'a', 'b'},       l [2]);
AssertAreSame (new[]{'a', 'b', 'c'},  l [3]);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Insert<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Insert<TSource> (this IEnumerable<TSource> self, TSource value)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
value
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Insert<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Insert<TSource> (this IEnumerable<TSource> self, TSource value, Func<TSource, TSource, int> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
value
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Intersperse<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Intersperse<TSource> (this IEnumerable<IEnumerable<TSource>> self, IEnumerable<TSource> between)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
between
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Intersperse<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> Intersperse<TSource> (this IEnumerable<TSource> self, TSource value)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
value
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

NotNull<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> NotNull<TSource> (this IEnumerable<Nullable<TSource>> self)
where TSource : struct

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Or Method

Documentation for this section has not yet been entered.

public static bool Or (this IEnumerable<bool> self)

Parameters

self
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

OrderByNatural<TSource> Generic Method

Documentation for this section has not yet been entered.

public static IEnumerable<TSource> OrderByNatural<TSource> (this IEnumerable<TSource> self, Func<TSource, string> func)

Type Parameters

TSource
Documentation for this section has not yet been entered.

Parameters

self
Documentation for this section has not yet been entered.
func
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Exceptions

Type Reason
ArgumentNullException Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Partition<TSource> Generic Method

Partitions self into two sequences, those which contain elements satisfying predicate and those which do not.

Type Parameters

TSource
The type of the elements in self.

Parameters

self
A IEnumerable<TSource> containing the sequence to partition into elements which match predicate and those which do not.
predicate
A Func<TSource, bool> which is used to partition self into the set of elements for which predicate returns true and those for which predicate returns false.

Returns

A Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>> in which Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>.Item1 contains the elements from self which satisfy predicate, and Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>.Item2 contains the elements which do not satisfy predicate.

Exceptions

Type Reason
ArgumentNullException self or predicate are null.

Remarks

C# Example
Tuple<IEnumerable<int>, IEnumerable<int>> r =
	Enumerable.Range (1,6).Partition (x => x % 2 == 0);
Assert.IsTrue (new[]{2, 4, 6}.SequenceEqual (r.Item1));
Assert.IsTrue (new[]{1, 3, 5}.SequenceEqual (r.Item2));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

PathCombine Method

Creates a path string by concatenating the elements of self.

public static string PathCombine (this IEnumerable<string> self)

Parameters

self
A IEnumerable<TSource> containing the values to combine into a path name.

Returns

A string which is the result of combining all the elements within self into a path name.

Exceptions

Type Reason
ArgumentException An element of self contains an invalid path character; see System.IO.Path.GetInvalidPathChars.
ArgumentNullException

self is null.

-or-

An element within self is null.

Remarks

Operation
For each element within self, if the current element is rooted (System.IO.Path.IsPathRooted(string)), then the current path string is dropped and the current element becomes the new path root. Otherwise, System.IO.Path.DirectorySeparatorChar is appended to the current path string and the current element is appended.
C# Example
var data = new [] {"a", "b", "c"};
var result = string.Format ("a{0}b{0}c", Path.DirectorySeparatorChar);
Assert.AreEqual (result, data.PathCombine ());

data = new [] { "a", String.Empty, "b", "c" };
Assert.AreEqual (result, data.PathCombine (), "empty elemetns");

string rooted = Path.DirectorySeparatorChar + "d";
data = new [] { "a", rooted };
Assert.AreEqual (rooted, data.PathCombine (), "rooted path2");

data = new [] { "a", "b", rooted, "c" };
string expected = Path.Combine (Path.Combine (Path.Combine ("a", "b"), rooted), "c");
Assert.AreEqual (expected, data.PathCombine (), "rooted path2 (complex)");

string end1 = "d" + Path.DirectorySeparatorChar;
data = new [] { rooted, end1, "e" };
expected = Path.Combine (Path.Combine (rooted, end1), "e");
Assert.AreEqual (expected, data.PathCombine (), "DirectorySeparatorChar");

string end2 = "d" + Path.AltDirectorySeparatorChar;
data = new [] { rooted, end2, "f" };
expected = Path.Combine (Path.Combine (rooted, end2), "f");
Assert.AreEqual (expected, data.PathCombine (), "AltDirectorySeparatorChar");

data = new [] { "a" };
Assert.AreEqual (Path.Combine ("a", String.Empty), data.PathCombine (), "single string");

data = new [] { String.Empty };
Assert.AreEqual (Path.Combine (String.Empty, String.Empty), data.PathCombine (), "single empty string");

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

RemoveFirstOccurrence<TSource> Generic Method

Removes the first occurrence of value from the sequence self.

public static IEnumerable<TSource> RemoveFirstOccurrence<TSource> (this IEnumerable<TSource> self, TSource value)

See Also

EnumerableCoda.RemoveFirstOccurrence``1(IEnumerable<``0>, ``0, IEqualityComparer<``0>)

Type Parameters

TSource
The type of the elements in self.

Parameters

self
A IEnumerable<TSource> containing the sequence from which to remove the first element equal to value.
value
A TSource which is the value to remove once from self.

Returns

A IEnumerable<TSource> which is a copy of self in which the first occurrence of value has been removed.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

This is equivalent to calling self.RemoveFirstOccurrence(value, null).

C# Example
Assert.AreEqual ("bnana",
		"banana".RemoveFirstOccurrence ('a').Implode ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

RemoveFirstOccurrence<TSource> Generic Method

Removes the first occurrence of value from the sequence self.

public static IEnumerable<TSource> RemoveFirstOccurrence<TSource> (this IEnumerable<TSource> self, TSource value, IEqualityComparer<TSource> comparer)

Type Parameters

TSource
The type of the elements in self.

Parameters

self
A IEnumerable<TSource> containing the sequence from which to remove the first element equal to value.
value
A TSource which is the value to remove once from self.
comparer
A IEqualityComparer<TSource> to use when comparing elements from self to value. If null then EqualityComparer<TSource>.Default is used.

Returns

A IEnumerable<TSource> which is a copy of self in which the first occurrence of value has been removed.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

C# Example
Assert.AreEqual ("bnana",
		"banana".RemoveFirstOccurrence ('a').Implode ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

RemoveFirstOccurrences<TSource> Generic Method

Removes the first count occurrences of value from the sequence self.

public static IEnumerable<TSource> RemoveFirstOccurrences<TSource> (this IEnumerable<TSource> self, TSource value, int count)

See Also

EnumerableCoda.RemoveFirstOccurrences``1(IEnumerable<``0>, ``0, int, IEqualityComparer<``0>)

Type Parameters

TSource
The type of the elements in self.

Parameters

self
A IEnumerable<TSource> containing the sequence from which to remove the leading elements equal to value from.
value
A TSource which is the value to remove from the start of self.
count
A int containing the number of value elements to remove from self.

Returns

A IEnumerable<TSource> which is a copy of self in which the first count occurrences of value have been removed.

Exceptions

Type Reason
ArgumentNullException self is null.
ArgumentOutOfRangeException count is negative.

Remarks

This is equivalent to calling self.RemoveFirstOccurrences(value, count, null).

C# Example
Assert.AreEqual ("bnna",
		"banana".RemoveFirstOccurrences ('a', 2).Implode ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

RemoveFirstOccurrences<TSource> Generic Method

Removes the first count occurrences of value from the sequence self.

public static IEnumerable<TSource> RemoveFirstOccurrences<TSource> (this IEnumerable<TSource> self, TSource value, int count, IEqualityComparer<TSource> comparer)

Type Parameters

TSource
The type of the elements in self.

Parameters

self
A IEnumerable<TSource> containing the sequence from which to remove the leading elements equal to value from.
value
A TSource which is the value to remove from the start of self.
count
A int containing the number of value elements to remove from self.
comparer
A IEqualityComparer<TSource> to use when comparing elements from self and value. If null then EqualityComparer<TSource>.Default is used.

Returns

A IEnumerable<TSource> which is a copy of self in which the first count occurrences of value have been removed.

Exceptions

Type Reason
ArgumentNullException self is null.
ArgumentOutOfRangeException count is negative.

Remarks

C# Example
Assert.AreEqual ("bnna",
		"banana".RemoveFirstOccurrences ('a', 2).Implode ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Repeat<TSource> Generic Method

Repeats the sequence self for number repetitions.

public static IEnumerable<TSource> Repeat<TSource> (this IEnumerable<TSource> self, int number)

Type Parameters

TSource
The type of the elements in self.

Parameters

self
A IEnumerable<TSource> containing the sequence to repeat.
number
The number of times to repeat self.

Returns

A IEnumerable<TSource> sequence containing count * self.Count() elements, consisting of the sequence self, followed by the sequence self, etc.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

C# Example
Assert.AreEqual ("foofoofoo", new [] {"foo"}.Repeat (3).Implode ());
Assert.AreEqual ("foobarfoobar", new [] {"foo", "bar"}.Repeat (2).Implode ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SelectAggregated<TSource,TAccumulate,TResult> Generic Method

Applies func to each element within self, returning the final value of the accumulator and the list of intermediate values.

public static Cadenza.Tuple<TAccumulate, List<TResult>> SelectAggregated<TSource, TAccumulate, TResult> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, Cadenza.Tuple<TAccumulate, TResult>> func)

Type Parameters

TSource
The type of the elements within self.
TAccumulate
The type of the accumulator value.
TResult
The type of the return value.

Parameters

self
A IEnumerable<TSource> containing the sequence to return the values of successive System.Linq.Enumerable.Select``2(IEnumerable<``0>, Func<``0, ``1>) and EnumerableCoda.AggregateReverse``3(IEnumerable<``0>, ``1, Func<``1, ``0, ``1>, Func<``1, ``2>) calls from.
seed
The first TAccumulate value to pass to func.
func
A Func<TAccumulate, TSource, Cadenza.Tuple<TAccumulate, TResult>> which is applied against each element within self and the current TAccumulate value (initially using seed), generating the next accumulated value and the (partial) result value.

Returns

A Cadenza.Tuple<TAccumulate, List<TResult>> which contains the final accumulated value in Cadenza.Tuple<TAccumulate, List<TResult>>.Item1 and the list of intermediate results in Cadenza.Tuple<TAccumulate, List<TResult>>.Item2.

Exceptions

Type Reason
ArgumentNullException self or func is null.

Remarks

This is Haskell's mapAccumL.

C# Example
IEnumerable<int> s = new []{2, 3, 4, 5};
Tuple<int, List<string>> r = s.SelectAggregated (1,
		(a,b) => Tuple.Create (a-b, "s" + (a-b)));
Assert.AreEqual (-13, r.Item1);
Assert.IsTrue (new[]{
		"s-1",
		"s-4",
		"s-8",
		"s-13",
}.SequenceEqual (r.Item2));

r = new int[]{}.SelectAggregated (42,
		(a,b) => Tuple.Create (a-b, b.ToString ()));
Assert.AreEqual (42, r.Item1);
Assert.AreEqual (0, r.Item2.Count);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SelectBreadthFirst<TSource,TResult> Generic Method

Traverse a sequence of nodes in a breadth-first fashion, converting each encountered node.

public static IEnumerable<TResult> SelectBreadthFirst<TSource, TResult> (this IEnumerable<TSource> self, Func<TSource, TResult> valueSelector, Func<TSource, IEnumerable<TSource>> childrenSelector)

Type Parameters

TSource
The type of the root nodes and intermediate nodes of the tree.
TResult
The type of the object to return.

Parameters

self
A IEnumerable<TSource> containing the elements to perform a breadth-first traversal on.
valueSelector
A Func<TSource, TResult> which is used to convert tree nodes into TResult instances.
childrenSelector
A Func<TSource, IEnumerable<TSource>> which returns the child nodes of root and all intermediate non-leaf nodes.

Returns

A IEnumerable<TResult> containing the result of applying valueSelector to all nodes encountered while traversing the forest self in a breadth-first fashion.

Exceptions

Type Reason
ArgumentNullException

self is null.

-or-

childrenSelector is null.

-or-

valueSelector is null.

Remarks

self is a "forest", a sequence of tree roots (siblings), wherein each node is a data structure containing a value and child nodes. The value is retrieved via valueSelector, and the children are obtained via childrenSelector.

Each node is traversed in a breadth-first fashion, with each encountered node is provided to valueSelector, and the values are returned.

Example

Given the TreeNode<T> declaration:

C# Example
class TreeNode<T>
{
	public TreeNode ()
	{
		Children = new TreeNode<T> [0];
	}

	public T Value;
	public IEnumerable<TreeNode<T>> Children;
}

SelectBreadthFirst() is used as:

C# Example
TreeNode<int>[] root = new TreeNode<int>[] {
	new TreeNode<int> {
		Value = 1, Children = new [] {
			new TreeNode<int> { Value = 2 },
			new TreeNode<int> {
				Value = 3, Children = new [] {
					new TreeNode<int> { Value = 5 },
				}
			},
			new TreeNode<int> { Value = 4 },
		}
	},
	new TreeNode<int> { Value = -1 },
};
IEnumerable<int> values = root
	.SelectBreadthFirst (x => x.Value, x => x.Children);
AssertAreSame (new[]{ 1, 2, 3, 4, 5, -1 }, values);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SelectDepthFirst<TSource,TResult> Generic Method

Traverse a sequence of nodes in a depth-first fashion, converting each encountered node.

public static IEnumerable<TResult> SelectDepthFirst<TSource, TResult> (this IEnumerable<TSource> self, Func<TSource, TResult> valueSelector, Func<TSource, IEnumerable<TSource>> childrenSelector)

Type Parameters

TSource
The type of the root nodes and intermediate nodes of the tree.
TResult
The type of the object to return.

Parameters

self
A IEnumerable<TSource> containing the elements to perform a depth-first traversal on.
valueSelector
A Func<TSource, TResult> which is used to convert tree nodes into TResult instances.
childrenSelector
A Func<TSource, IEnumerable<TSource>> which returns the child nodes of an element in self (and grand-children, and great-grandchildren, and...).

Returns

A IEnumerable<TResult> containing the result of applying valueSelector to all nodes encountered while traversing the forest self in a depth-first fashion.

Exceptions

Type Reason
ArgumentNullException

self is null.

-or-

childrenSelector is null.

-or-

valueSelector is null.

Remarks

self is a "forest", a sequence of tree roots (siblings), wherein each node is a data structure containing a value and child nodes. The value is retrieved via valueSelector, and the children are obtained via childrenSelector.

The tree is traversed in a depth-first fashion, each encountered node is provided to valueSelector, and the values are returned.

Example

Given the TreeNode<T> declaration:

C# Example
class TreeNode<T>
{
	public TreeNode ()
	{
		Children = new TreeNode<T> [0];
	}

	public T Value;
	public IEnumerable<TreeNode<T>> Children;
}

SelectDepthFirst() is used as:

C# Example
TreeNode<int>[] root = new TreeNode<int>[] {
	new TreeNode<int> {
		Value = 1, Children = new [] {
			new TreeNode<int> { Value = 2 },
			new TreeNode<int> {
				Value = 3, Children = new [] {
					new TreeNode<int> { Value = 5 },
				}
			},
			new TreeNode<int> { Value = 4 },
		}
	},
	new TreeNode<int> { Value = -1 },
};
IEnumerable<int> values = root
	.SelectDepthFirst (x => x.Value, x => x.Children);
AssertAreSame (new[]{ 1, 2, 3, 5, 4, -1 }, values);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SelectFromEach<T1,T2,TResult> Generic Method

Projects each corresponding element from multiple sequences into a new form.

public static IEnumerable<TResult> SelectFromEach<T1, T2, TResult> (this IEnumerable<T1> self, IEnumerable<T2> source2, Func<T1, T2, TResult> selector)

See Also

EnumerableCoda.Zip``2(IEnumerable<``0>, IEnumerable<``1>)

Type Parameters

T1
The type of elements in the first list.
T2
The type of elements in the second list.
TResult
The type of value returned by selector.

Parameters

self
A IEnumerable<T1> containing elements from the first list.
source2
A IEnumerable<T2> containing elements from the second list.
selector
A Func<T1, T2, TResult> which is used to transform the corresponding elements from lists self and source2 into the returned value.

Returns

An IEnumerable<TResult> whose elements are the resulting of invoking selector on each corresponding element of self and source2.

Exceptions

Type Reason
ArgumentNullException self, source2, or selector is null.

Remarks

Returns an IEnumerable<TResult> where each TResult value is the result of applying selector to an element from each of self, and source2 with the same element index.

The number of items in the list returned is equal to the shorter of self and source2.

C# Example
List<int>  a = new List<int> {1, 2, 3, 4};
List<char> b = new List<char> {'a', 'b', 'c', 'd', 'e'};
var c = a.SelectFromEach (b, (x, y) => new { First = x, Second = y }).ToList ();
Assert.AreEqual (4, c.Count);
Assert.AreEqual (1,   c [0].First);
Assert.AreEqual ('a', c [0].Second);
Assert.AreEqual (2,   c [1].First);
Assert.AreEqual ('b', c [1].Second);
Assert.AreEqual (3,   c [2].First);
Assert.AreEqual ('c', c [2].Second);
Assert.AreEqual (4,   c [3].First);
Assert.AreEqual ('d', c [3].Second);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SelectFromEach<T1,T2,T3,TResult> Generic Method

Projects each corresponding element from multiple sequences into a new form.

public static IEnumerable<TResult> SelectFromEach<T1, T2, T3, TResult> (this IEnumerable<T1> self, IEnumerable<T2> source2, IEnumerable<T3> source3, Func<T1, T2, T3, TResult> selector)

See Also

EnumerableCoda.Zip``3(IEnumerable<``0>, IEnumerable<``1>, IEnumerable<``2>)

Type Parameters

T1
The type of elements in the first list.
T2
The type of elements in the second list.
T3
The type of elements in the third list.
TResult
The type of value returned by selector.

Parameters

self
A IEnumerable<T1> containing elements from the first list.
source2
A IEnumerable<T2> containing elements from the second list.
source3
A IEnumerable<T3> containing elements from the third list.
selector
A Func<T1, T2, T3, TResult> which is used to transform the corresponding elements from lists self, source2, and source3 into the returned value.

Returns

An IEnumerable<TResult> whose elements are the resulting of invoking selector on each corresponding element of self, source2, and source3.

Exceptions

Type Reason
ArgumentNullException self, source2, source3, or selector is null.

Remarks

Returns an IEnumerable<TResult> where each TResult value is the result of applying selector to an element from each of self, source2, and source3 with the same element index.

The number of items in the list returned is equal to the shorter of self, source2, and source3.

C# Example
Assert.AreEqual ("123",
		new[]{1}.SelectFromEach (new[]{2}, new[]{3}, 
			(x,y,z) => x.ToString () + y.ToString () + z.ToString ()).Implode ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SelectFromEach<T1,T2,T3,T4,TResult> Generic Method

Projects each corresponding element from multiple sequences into a new form.

public static IEnumerable<TResult> SelectFromEach<T1, T2, T3, T4, TResult> (this IEnumerable<T1> self, IEnumerable<T2> source2, IEnumerable<T3> source3, IEnumerable<T4> source4, Func<T1, T2, T3, T4, TResult> selector)

See Also

EnumerableCoda.Zip``4(IEnumerable<``0>, IEnumerable<``1>, IEnumerable<``2>, IEnumerable<``3>)

Type Parameters

T1
The type of elements in the first list.
T2
The type of elements in the second list.
T3
The type of elements in the third list.
T4
The type of elements in the fourth list.
TResult
The type of value returned by selector.

Parameters

self
A IEnumerable<T1> containing elements from the first list.
source2
A IEnumerable<T2> containing elements from the second list.
source3
A IEnumerable<T3> containing elements from the third list.
source4
A IEnumerable<T4> containing elements from the fourth list.
selector
A Func<T1, T2, T3, T4, TResult> which is used to transform the corresponding elements from lists self, source2, source3, and source4 into the returned value.

Returns

An IEnumerable<TResult> whose elements are the resulting of invoking selector on each corresponding element of self, source2, source3, and source4.

Exceptions

Type Reason
ArgumentNullException self, source2, source3, source4, or selector is null.

Remarks

Returns an IEnumerable<TResult> where each TResult value is the result of applying selector to an element from each of self, source2, source3, and source4 with the same element index.

The number of items in the list returned is equal to the shorter of self, source2, source3, and source4.

C# Example
Assert.AreEqual ("1234",
		new[]{1}.SelectFromEach (new[]{2}, new[]{3}, new[]{4},
			(w,x,y,z) => w.ToString () + x.ToString () + y.ToString () + z.ToString ()).Implode ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SelectReverseAggregated<TSource,TAccumulate,TResult> Generic Method

Applies func to each element within self in reverse order, returning the final value of the accumulator and the list of intermediate values.

public static Cadenza.Tuple<TAccumulate, List<TResult>> SelectReverseAggregated<TSource, TAccumulate, TResult> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, Cadenza.Tuple<TAccumulate, TResult>> func)

Type Parameters

TSource
The type of the elements within self.
TAccumulate
The type of the accumulator value.
TResult
The type of the return value.

Parameters

self
A IEnumerable<TSource> containing the sequence to return the values of successive System.Linq.Enumerable.Select``2(IEnumerable<``0>, Func<``0, ``1>) and EnumerableCoda.AggregateReverse``3(IEnumerable<``0>, ``1, Func<``1, ``0, ``1>, Func<``1, ``2>) calls from.
seed
The first TAccumulate value to pass to func.
func
A Func<TAccumulate, TSource, Cadenza.Tuple<TAccumulate, TResult>> which is applied against each element within self in reverse order and the current TAccumulate value (initially using seed), generating the next accumulated value and the (partial) result value.

Returns

A Cadenza.Tuple<TAccumulate, List<TResult>> which contains the final accumulated value in Cadenza.Tuple<TAccumulate, List<TResult>>.Item1 and the list of intermediate results in Cadenza.Tuple<TAccumulate, List<TResult>>.Item2.

Exceptions

Type Reason
ArgumentNullException self or func is null.

Remarks

This is Haskell's mapAccumR.

C# Example
IEnumerable<int> s = new []{1, 2, 3, 4};
Tuple<int, List<string>> r = s.SelectReverseAggregated (5,
		(a,b) => Tuple.Create (a-b, "s" + (a-b)));
Assert.AreEqual (-5, r.Item1);
Assert.IsTrue (new[]{
	"s1",
	"s-2",
	"s-4",
	"s-5",
}.SequenceEqual (r.Item2));

r = new int[]{}.SelectReverseAggregated (42,
		(a,b) => Tuple.Create (a-b, b.ToString ()));
Assert.AreEqual (42, r.Item1);
Assert.AreEqual (0, r.Item2.Count);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SequenceCompare<TSource> Generic Method

Compares the elements of two sequences by using the default comparer for their type.

public static int SequenceCompare<TSource> (this IEnumerable<TSource> self, IEnumerable<TSource> list)

See Also

EnumerableCoda.SequenceCompare``1(IEnumerable<``0>, IEnumerable<``0>, IComparer<``0>)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to compare against list.
list
A IEnumerable<TSource> containing the sequence to compare against self.

Returns

An int which is:
ValueCondition
Less than zero The default comparer returned less than zero when comparing element x at index i from sequence self against element y at index i from sequence list, or self had more elements than list (and all elements in list were equal to their corresponding elements within self).
Zero The default comparer returned zero for all elements whe comparing element x at index i from sequence self against element y at index i from sequence list, and self and list have the same number of elements.
Greater than zero The default comparer returned greater than zero when comparing element x at index i from sequence self against element y at index i from sequence list, or list had more elements than self (and all elements in self were equal to their corresponding elements within list).

Exceptions

Type Reason
ArgumentNullException self or list is null.

Remarks

This is the IComparer<TSource> analog to System.Linq.Enumerable.SequenceEqual``1(IEnumerable<``0>, IEnumerable<``0>).

This method enumerates self and list in parallel and compares corresponding elements by using the default IComparer<TSource>. It returns non-zero the first time the default comparer returns non-zero. If it runs out of elements, then it will return less than zero if self still contains elements, will return zero if neither self nor list contain elements, and will return greater than zero if list still contains elements.

C# Example
Assert.AreEqual (0,
		new[]{1, 2}.SequenceCompare (new[]{1, 2}));
Assert.AreEqual (-1,
		new[]{1, 1}.SequenceCompare (new[]{1, 2}));
Assert.AreEqual (1,
		new[]{1, 3}.SequenceCompare (new[]{1, 2}));
Assert.AreEqual (-1,
		new[]{1, 2}.SequenceCompare (new[]{1}));
Assert.AreEqual (1,
		new[]{1}.SequenceCompare (new[]{1, 2}));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SequenceCompare<TSource> Generic Method

Compares the elements of two sequences by using a specified IComparer<TSource>.

public static int SequenceCompare<TSource> (this IEnumerable<TSource> self, IEnumerable<TSource> list, IComparer<TSource> comparer)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to compare against list.
list
A IEnumerable<TSource> containing the sequence to compare against self.
comparer
A IComparer<TSource> which is used to compare elements from self and list are to each other. If null, then Comparer<TSource>.Default is used.

Returns

An int which is:
ValueCondition
Less than zerocomparer.Compare(x, y) returned less than zero when comparing element x at index i from sequence self against element y at index i from sequence list, or self had more elements than list (and all elements in list were equal to their corresponding elements within self).
Zerocomparer.Compare(x, y) returned zero for all elements whe comparing element x at index i from sequence self against element y at index i from sequence list, and self and list have the same number of elements.
Greater than zerocomparer.Compare(x, y) returned greater than zero when comparing element x at index i from sequence self against element y at index i from sequence list, or list had more elements than self (and all elements in self were equal to their corresponding elements within list).

Exceptions

Type Reason
ArgumentNullException self or list is null.

Remarks

This is the IComparer<TSource> analog to System.Linq.Enumerable.SequenceEqual``1(IEnumerable<``0>, IEnumerable<``0>, IEqualityComparer<``0>).

This method enumerates self and list in parallel and compares corresponding elements by using the specified IComparer<TSource>. It returns non-zero the first time comparer returns non-zero. If it runs out of elements, then it will return less than zero if self still contains elements, will return zero if neither self nor list contain elements, and will return greater than zero if list still contains elements.

C# Example
Assert.AreEqual (0,
		new[]{1, 2}.SequenceCompare (new[]{1, 2}));
Assert.AreEqual (-1,
		new[]{1, 1}.SequenceCompare (new[]{1, 2}));
Assert.AreEqual (1,
		new[]{1, 3}.SequenceCompare (new[]{1, 2}));
Assert.AreEqual (-1,
		new[]{1, 2}.SequenceCompare (new[]{1}));
Assert.AreEqual (1,
		new[]{1}.SequenceCompare (new[]{1, 2}));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Shuffle<TSource> Generic Method

Randomizes the ordering of items within self.

public static IEnumerable<TSource> Shuffle<TSource> (this IEnumerable<TSource> self)

See Also

EnumerableCoda.Shuffle``1(IEnumerable<``0>,System.Random)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to remove prefix from.

Returns

A new IEnumerable<TSource> with the same number of elements as self except that the elements returned may be in a different order. The order of the elements returned is controlled by random.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

This is equivalent to calling Shuffle(self, null).

C# Example
IEnumerable<int> r = new[]{1,2,3,4,5}.Shuffle ();
Assert.AreEqual (5, r.Count());
Assert.IsTrue (r.Contains (1));
Assert.IsTrue (r.Contains (2));
Assert.IsTrue (r.Contains (3));
Assert.IsTrue (r.Contains (4));
Assert.IsTrue (r.Contains (5));

Assert.IsFalse (r.Contains (0));
Assert.IsFalse (r.Contains (6));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Shuffle<TSource> Generic Method

Randomizes the ordering of items within self.

public static IEnumerable<TSource> Shuffle<TSource> (this IEnumerable<TSource> self, Random random)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to remove prefix from.
random
A Random instance to get random numbers from.

Returns

A new IEnumerable<TSource> with the same number of elements as self except that the elements returned may be in a different order. The order of the elements returned is controlled by random.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

Operation
Calls Random.Next(int) once for each element within self to partially determine the element's position within the returned sequence, then creates a new sequence based on the random element ordering.
C# Example
IEnumerable<int> r = new[]{1,2,3,4,5}.Shuffle ();
Assert.AreEqual (5, r.Count());
Assert.IsTrue (r.Contains (1));
Assert.IsTrue (r.Contains (2));
Assert.IsTrue (r.Contains (3));
Assert.IsTrue (r.Contains (4));
Assert.IsTrue (r.Contains (5));

Assert.IsFalse (r.Contains (0));
Assert.IsFalse (r.Contains (6));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SkipPrefix<TSource> Generic Method

Skips over prefix, returning the elements following prefix.

public static IEnumerable<TSource> SkipPrefix<TSource> (this IEnumerable<TSource> self, IEnumerable<TSource> prefix)

See Also

EnumerableCoda.SkipPrefix``1(IEnumerable<``0>, IEnumerable<``0>, IEqualityComparer<``0>)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to remove prefix from.
prefix
A IEnumerable<TSource> containing the sequence to remove from the start of self.

Returns

A IEnumerable<TSource> if self begins with prefix which contains the elements within self following the sequence within prefix. If self does not start with prefix, then null is returned.

Exceptions

Type Reason
ArgumentNullException self or prefix is null.

Remarks

This is equivalent to calling SkipPrefix(self, prefix, null).

C# Example
Assert.AreEqual ("bar",
		"foobar".SkipPrefix ("foo").Implode ());
Assert.AreEqual ("",
		"foo".SkipPrefix ("foo").Implode ());
Assert.AreEqual (null,
		"barfoo".SkipPrefix ("foo"));
Assert.AreEqual (null,
		"barfoobaz".SkipPrefix ("foo"));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SkipPrefix<TSource> Generic Method

Skips over prefix, returning the elements following prefix.

public static IEnumerable<TSource> SkipPrefix<TSource> (this IEnumerable<TSource> self, IEnumerable<TSource> prefix, IEqualityComparer<TSource> comparer)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to remove prefix from.
prefix
A IEnumerable<TSource> containing the sequence to remove from the start of self.
comparer
A IEqualityComparer<TSource> to use to compare elements between the self and prefix sequences. If null then EqualityComparer<TSource>.Default is used.

Returns

A IEnumerable<TSource> if self begins with prefix which contains the elements within self following the sequence within prefix. If self does not start with prefix, then null is returned.

Exceptions

Type Reason
ArgumentNullException self or prefix is null.

Remarks

C# Example
Assert.AreEqual ("bar",
		"foobar".SkipPrefix ("foo").Implode ());
Assert.AreEqual ("",
		"foo".SkipPrefix ("foo").Implode ());
Assert.AreEqual (null,
		"barfoo".SkipPrefix ("foo"));
Assert.AreEqual (null,
		"barfoobaz".SkipPrefix ("foo"));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Sort<TSource> Generic Method

Sorts the elements in the sequence self using the default comparer.

public static IEnumerable<TSource> Sort<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to sort by the default comparer.

Returns

A IEnumerable<TSource> containing the elements within self sorted by the default comparer.

Exceptions

Type Reason
ArgumentNullException self is null.
InvalidOperationException The default comparer Comparer<TSource>.Default cannot find ain implementation of the IComparer<TSource> generic interface or the IComparer interface for the type TSource.

Remarks

Use this method instead of the System.Linq.Enumerable.OrderBy``2(IEnumerable<``0>, Func<``0, ``1>) method when you don't need to do anything "fancy," as this can result in faster execution. For example, when sorting 20 million integers, the Sort() extension method can be upwards of 4x faster than the equivalent OrderBy(e => e) extension method call.

Operation
This method creates a List<TSource> over self, invokes List<TSource>.Sort and returns the list.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Sort<TSource> Generic Method

Sorts the elements in the sequence self using the specified comparer.

public static IEnumerable<TSource> Sort<TSource> (this IEnumerable<TSource> self, IComparer<TSource> comparer)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to sort by the default comparer.
comparer
A IComparer<TSource> instance which is used to sort the elements within self. If null, then Comparer<TSource>.Default is used.

Returns

A IEnumerable<TSource> containing the elements within self sorted by the default comparer.

Exceptions

Type Reason
ArgumentNullException self is null.
InvalidOperationException comparer is null and the default comparer Comparer<TSource>.Default cannot find ain implementation of the IComparer<TSource> generic interface or the IComparer interface for the type TSource.

Remarks

Use this method instead of the System.Linq.Enumerable.OrderBy``2(IEnumerable<``0>, Func<``0, ``1>, IComparer<``1>) method when you don't need to do anything "fancy," as this can result in faster execution. For example, when sorting 20 million integers, the Sort() extension method can be upwards of 4x faster than the equivalent OrderBy(e => e) extension method call.

Operation
This method creates a List<TSource> over self, invokes List<TSource>.Sort(IComparer<`0>) and returns the list.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Sort<TSource> Generic Method

Sorts the elements in the sequence self using the specified comparer.

public static IEnumerable<TSource> Sort<TSource> (this IEnumerable<TSource> self, Comparison<TSource> comparison)

Type Parameters

TSource
The type of the elements within self.

Parameters

self
A IEnumerable<TSource> containing the sequence to sort by the default comparer.
comparison
A Comparison<TSource> instance which is used to sort the elements within self.

Returns

A IEnumerable<TSource> containing the elements within self sorted by the default comparer.

Exceptions

Type Reason
ArgumentNullException self or comparison is null.
ArgumentException The implementation of comparison caused an error during the sort. For example, comparison might not return 0 when comparing an item with itself.

Remarks

Use this method instead of the System.Linq.Enumerable.OrderBy``2(IEnumerable<``0>, Func<``0, ``1>) method when you don't need to do anything "fancy," as this can result in faster execution. For example, when sorting 20 million integers, the Sort() extension method can be upwards of 4x faster than the equivalent OrderBy(e => e) extension method call.

Operation
This method creates a List<TSource> over self, invokes List<TSource>.Sort(Comparer<`0>) and returns the list.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SortNatural Method

Returns a new IEnumerable<TSource> which contains the elements within self sorted using the Cadenza.NaturalStringComparer.Default comparer.

public static IEnumerable<string> SortNatural (this IEnumerable<string> self)

Parameters

self
A IEnumerable<TSource> containing the elements to sort.

Returns

A new IEnumerable<TSource> which contains the elements within self sorted using the Cadenza.NaturalStringComparer.Default comparer.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

This method does not modify self.

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Span<TSource> Generic Method

Creates a Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>> of the contiguous elements at the start of self which satisfy predicate.

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<TSource> containing the sequence to create a span of.
predicate
A Func<TSource, bool> which controls which elements from self are present within the returned Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>._1. sequence.

Returns

Creates a Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>; Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>._1 contains the (possibly empty) sequence of elements at the start of self which satisfy predicate, and Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>._2 contains all remaining elements from self.

Exceptions

Type Reason
ArgumentNullException self or predicate is null.

Remarks

This is equivalent to: Tuple.Create (self.TakeWhile (predicate), self.SkipWhile (predicate));.

C# Example
Assert.AreEqual ("12|341234",
		new[]{1,2,3,4,1,2,3,4}.Span (e => e < 3)
		.Aggregate ((x, y) => x.Implode () + "|" + y.Implode ()));
Assert.AreEqual ("123|",
		new[]{1,2,3}.Span (e => e < 9)
		.Aggregate ((x, y) => x.Implode () + "|" + y.Implode ()));
Assert.AreEqual ("|123",
		new[]{1,2,3}.Span (e => e < 0)
		.Aggregate ((x, y) => x.Implode () + "|" + y.Implode ()));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

SplitAt<TSource> Generic Method

Splits self at firstLength, creating a Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>.

public static Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>> SplitAt<TSource> (this IEnumerable<TSource> self, int firstLength)

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<TSource> containing the sequence to split.
firstLength
The number of elements to return in the first created sequence.

Returns

A Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>, where Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>._1 contains the first firstLength elements from self, and Cadenza.Tuple<IEnumerable<TSource>, IEnumerable<TSource>>._2 contains the remaining elements from the sequence.

Exceptions

Type Reason
ArgumentNullException self is null.
ArgumentOutOfRangeException firstLength is negative.

Remarks

This is equivalent to Tuple.Create (self.Take (firstLength), self.Skip (firstLength));.

C# Example
Assert.AreEqual ("Hello |World!",
		"Hello World!".SplitAt (6)
		.Aggregate ((x,y) => x.Implode () + "|" + y.Implode ()));
Assert.AreEqual ("123|45",
		new[]{1,2,3,4,5}.SplitAt (3)
		.Aggregate ((x,y) => x.Implode () + "|" + y.Implode ()));
Assert.AreEqual ("1|23",
		new[]{1,2,3}.SplitAt (1)
		.Aggregate ((x,y) => x.Implode () + "|" + y.Implode ()));
Assert.AreEqual ("123|",
		new[]{1,2,3}.SplitAt (3)
		.Aggregate ((x,y) => x.Implode () + "|" + y.Implode ()));
Assert.AreEqual ("123|",
		new[]{1,2,3}.SplitAt (4)
		.Aggregate ((x,y) => x.Implode () + "|" + y.Implode ()));
Assert.AreEqual ("|123",
		new[]{1,2,3}.SplitAt (0)
		.Aggregate ((x,y) => x.Implode () + "|" + y.Implode ()));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Subsets<TSource> Generic Method

Creates all subsets of a given input sequence.

public static IEnumerable<IEnumerable<TSource>> Subsets<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<TSource> containing the sequence to create subsets from.

Returns

An unordered IEnumerable<IEnumerable<TSource>> that contains all subsets of source including the set self itself.

Exceptions

Type Reason
ArgumentNullException If self is null (Nothing in VB).
InvalidOperationException If self contains more than 63 items. Important, this will only be thrown when you start enumerating the results.

Remarks

This creates all subsets from the sequence self.

Sequences greater than 63 items are not supported and will throw a InvalidOperationException when you try to enumerate the results.

Example
Given the input sequence, [a, b, c] the result would be:
[a]
[b]
[a,b]
[c]
[a,c]
[b,c]
[a,b,c]

Note: This method does not remove duplicates from self. If self may contain duplicates and you want true subsets use System.Linq.Enumerable.Distinct<TSource> first, e.g. source.Distinct().Subsets().

Note: This method does not guarantee any order to the results so future implementations may return the results in a different order.

Note: This keep the input sizes small, as the result set will contain (n ^ 2) - 1 results, eg for 20 items there are 1,048,575 subsets.

Example

C# Example
List<string> source = new List<string> { "a", "b", "c" };
IEnumerable<IEnumerable<string>> results = source.Subsets ();

foreach (IEnumerable<string> subset in results) {

  foreach (string value in subset) {
    Console.Write (value);
    Console.Write (" ");
  }

  Console.WriteLine ();
}
VB Example
Dim source As New List (Of String) (New String () { "a", "b", "c" })
Dim results As IEnumerable (Of IEnumerable (Of String)) = source.Subsets ()

For Each subset As IEnumerable (Of String) In results

  For Each value As String In subset
    Console.Write (value)
    Console.Write (" ")
  Next
  
  Console.WriteLine ()
Next

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Subsets<TSource> Generic Method

Creates all subsets that match predicate.

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<TSource> containing the sequence to create subsets from.
predicate
A Func<TSource, bool> used to filter .

Returns

An unordered IEnumerable<IEnumerable<TSource>> that contains all subsets of source including the set self itself, excluding any sets and all their supersets that did not match the predicate.

Exceptions

Type Reason
ArgumentNullException If self is null (Nothing in VB).

Remarks

This creates all subsets from the sequence self, excluding any sets and their supersets that were filtered out by predicate.

Example
Given the input sequence, [a, b, c] and filtering out anything containing the subset [a, b] the result would be:
[a]
[b]
[c]
[a,c]
[b,c]

Note: This method does not remove duplicates from self. If self may contain duplicates and you want true subsets use System.Linq.Enumerable.Distinct<TSource> first, e.g. source.Distinct().Subsets(predicate).

Note: This method does not guarantee any order to the results so future implementations may return the results in a different order.

Example

C# Example
List<string> source = new List<string> { "a", "b", "c" };
IEnumerable<IEnumerable<string>> results = source.Subsets (x => !(x.Contains ("a") && x.Contains ("b")));

foreach (IEnumerable<string> subset in results) {

  foreach (string value in subset) {
    Console.Write (value);
    Console.Write (" ");
  }

  Console.WriteLine ();
}
VB Example
Dim source As New List (Of String) (New String () { "a", "b", "c" })
Dim results As IEnumerable (Of IEnumerable (Of String)) = source.Subsets (Function (x) Not (x.Contains ("a") AndAlso x.Contains ("b")))

For Each subset As IEnumerable (Of String) In results

  For Each value As String In subset
    Console.Write (value)
    Console.Write (" ")
  Next

  Console.WriteLine ()
Next

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Tokens<TSource,TAccumulate,TResult> Generic Method

A simple lexer to convert an IEnumerable<TSource> into a IEnumerable<TResult>, where the resulting sequence may have a different number of elements than the source sequence.

public static IEnumerable<TResult> Tokens<TSource, TAccumulate, TResult> (this IEnumerable<TSource> self, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulate, Func<TAccumulate, Cadenza.Tuple<TResult, TAccumulate>> resultSelector, params Func<TAccumulate, TSource, bool>[] categories)

Type Parameters

TSource
The type of elements within self.
TAccumulate
The type of the accumulator value.
TResult
The type of the resulting sequence of values.

Parameters

self
A IEnumerable<TSource> containing the values to aggregate and convert.
seed
The initial accumulator value.
accumulate
A Func<TAccumulate, TSource, TAccumulate> which is used to accumulate values from self into one of the values returned.
resultSelector
A Func<TAccumulate, Cadenza.Tuple<TResult, TAccumulate>> which is used to do two things: convert the accumulated value into a return value, and reset the accumulator. The Cadenza.Tuple<TResult, TAccumulate>.Item1 property contains the value to return, while the Cadenza.Tuple<TResult, TAccumulate>.Item2 property contains the new accumulator seed value.
categories
A Func<TAccumulate, TSource, bool> array which contains "categories." A "category" is how Tokens knows when to call accumulate or resultSelector. If a category returns true on an element from self, then accumulate will be invoked; otherwise, resultSelector is invoked.

Returns

An IEnumerable<TResult> containing the resulting "tokens" that accumulator and resultSelector produced.

Exceptions

Type Reason
ArgumentException categories contains no elements.
ArgumentNullException self, accumulate, resultSelector, or categories is null.

Remarks

This is either a very simple lexer, or the unholy combination of System.Linq.Enumerable.Select``2(IEnumerable<``0>, Func<``0, ``1>) and System.Linq.Enumerable.Aggregate``3(IEnumerable<``0>, ``1, Func<``1, ``0, ``1>, Func<``1, ``2>). You decide.

Tokens allows converting the source sequence self of length N into a resulting sequence of length M, where N can differ from M, and M can be greater than one. (This differs from Enumerable.Select(), where the resulting sequence has the same number of elements as the source sequence, and it differs from Enumerable.Aggregate(), where only a single value is returned.)

Operation

For each element in self, get the "category index" for the element. The "category index" is the first index into the categories array for which a Func<TAccumulate, TSource, bool> returns true. Then one of three things happens:

  1. If the category index is the same as the previous element's category index, then accumulate is invoked with the current accumulated value and the current element.
  2. If the category index differs from the previous element's category index, then resultSelector is invoked to obtain a Cadenza.Tuple<TResult, TAccumulate>. The Cadenza.Tuple<TResult, TAccumulate>.Item1 value is yielded from Tokens as one of the return values, and Cadenza.Tuple<TResult, TAccumulate>.Item2 is used as the new seed value for the next accumulate call.
  3. If no matching category is found (i.e. all entries in categories return false), then the element is ignored.

This use of "categories" and matching indexes allows for implementing precedence rules in a straightforward manner: if the category index differs, the accumulated token must have a different precedence, and thus should be returned and the accumulation process restarted.

C# Example
// Turn a sequence of numbers into a new sequence of numbers
// for which the sum is less than 10.
IEnumerable<int>  numbers         = new[]{1, 1, 3, 5, 8, 13};
IEnumerable<int>  sumsLessThan10  = numbers.Tokens (0,
		// accumulate: add the values together.
		// p=previous value, c=current value
		(p, c) => p + c,
		// resultSelector: return the current sum and reset count to 0.
		r => Tuple.Create (r, 0),
		// category: sum is less than 10.
		(p, c) => p + c < 10
);
// Notice that the input value of 13 is missing, as it didn't match
// any category.
Assert.IsTrue (new[]{5, 5, 8}.SequenceEqual (sumsLessThan10));

// More "traditional" lexing, with categories as precedence rules
string expression = " function(value1+value2)  ";
IEnumerable<string> exprTokens = expression.Tokens ("",
		// accumulate: concatenate the characters together
		(p, c) => p + c,
		r => Tuple.Create (r, ""),
		// category: identifiers: [A-Za-z_][A-Za-z0-9_]*
		(p, c) => p.Length == 0
			? char.IsLetter (c) || c == '_'
			: char.IsLetterOrDigit (c) || c == '_',
		// category: arithmetic operators
		(p, c) => c == '+' || c == '-' || c == '*' || c == '/',
		// category: grouping
		(p, c) => c == '(' || c == ')'
);
// Notice that all whitespace has been removed
Assert.IsTrue (
		new[]{"function", "(", "value1", "+", "value2", ")"}
		.SequenceEqual (exprTokens));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ToList<TSource> Generic Method

Creates a List<List<TSource>> with the same ordering and values as self.

public static List<List<TSource>> ToList<TSource> (this IEnumerable<IEnumerable<TSource>> self)

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<IEnumerable<TSource>> to convert into a List<List<TSource>>

Returns

A List<List<TSource>> with the same ordering and values as self.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

C# Example
int[][] a = new int[][]{
	new int[]{1, 2, 3},
	new int[]{4, 5, 6},
};
IEnumerable<IEnumerable<int>> b = a;
List<List<int>> c = b.ToList ();
Assert.AreEqual (a.Length, c.Count);
Assert.AreEqual (a [0].Length, c [0].Count);
Assert.AreEqual (a [1].Length, c [1].Count);
Assert.AreEqual (a [0][0], c [0][0]);
Assert.AreEqual (a [0][1], c [0][1]);
Assert.AreEqual (a [0][2], c [0][2]);
Assert.AreEqual (a [1][0], c [1][0]);
Assert.AreEqual (a [1][1], c [1][1]);
Assert.AreEqual (a [1][2], c [1][2]);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ToReadOnlyDictionary<TSource,TKey> Generic Method

Creates a Cadenza.Collections.ReadOnlyDictionary<TKey, TSource> from an IEnumerable<TSource> according to a specified key selector and value selector delegate.

public static ReadOnlyDictionary<TKey, TSource> ToReadOnlyDictionary<TSource, TKey> (this IEnumerable<TSource> self, Func<TSource, TKey> keySelector)

Type Parameters

TSource
The type of the elements in self.
TKey
The type of the key returned by keySelector.

Parameters

self
An IEnumerable<TSource> to create a Cadenza.Collections.ReadOnlyDictionary<TKey, TValue> from.
keySelector
A Func<TSource, TKey> used to extract a key from each element in self.

Returns

A Cadenza.Collections.ReadOnlyDictionary<TKey, TSource> which contains the key/value values from self.

Exceptions

Type Reason
ArgumentNullException

self, keySelector, or valueSelector is null.

-or-

keySelector produces a key that is null.

Remarks

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ToReadOnlyDictionary<TSource,TKey,TValue> Generic Method

Creates a Cadenza.Collections.ReadOnlyDictionary<TKey, TValue> from an IEnumerable<TSource> according to a specified key selector and value selector delegate.

public static ReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TSource, TKey, TValue> (this IEnumerable<TSource> self, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector)

Type Parameters

TSource
The type of the elements in self.
TKey
The type of the key returned by keySelector.
TValue
The type of the value returned by valueSelector.

Parameters

self
An IEnumerable<TSource> to create a Cadenza.Collections.ReadOnlyDictionary<TKey, TValue> from.
keySelector
A Func<TSource, TKey> used to extract a key from each element in self.
valueSelector
A Func<TSource, TValue> used to extract a value from each element in self.

Returns

A Cadenza.Collections.ReadOnlyDictionary<TKey, TValue> which contains the key/value values from self.

Exceptions

Type Reason
ArgumentNullException

self, keySelector, or valueSelector is null.

-or-

keySelector produces a key that is null.

Remarks

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ToTuple Method

Creates a Tuple from a sequence.

public static object ToTuple (this IEnumerable self)

Parameters

self
A IEnumerable containing the values to insert into a Tuple.

Returns

A object backed by a Tuple containing the values within the sequence self.

No specific tuple is returned, as it depends upon the number of elements within self, thus a cast is necessary to the appropriate Tuple type to use it as a Tuple.

Exceptions

Type Reason
ArgumentNullException self is null.
NotSupportedException The number of elements within self exceeds Cadenza.Tuple.MaxValues, and thus no tuple type exists to contain all the elements within self.

Remarks

Converts a sequence into a Tuple. The specific tuple returned is dependent upon self. self must have between 1 and Cadenza.Tuple.MaxValues elements, inclusive, otherwise a NotSupportedException is thrown.

C# Example
IEnumerable<object> s = new object[]{1, '2', 3L, "4"};
object tl = s.ToTuple ();
Assert.AreEqual (typeof(Tuple<int, char, long, string>), tl.GetType());

var t = (Tuple<int, char, long, string>) tl;
Assert.AreEqual (1,   t.Item1);
Assert.AreEqual ('2', t.Item2);
Assert.AreEqual (3L,  t.Item3);
Assert.AreEqual ("4", t.Item4);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ToValueReader Method

Creates a Cadenza.IO.TextValueReader which will extract values from an IEnumerable<string>.

[System.CLSCompliant(false)]
public static Cadenza.IO.TextValueReader ToValueReader (this IEnumerable<string> self)

Parameters

self
A IEnumerable<string> containing elements to read values from.

Returns

A Cadenza.IO.TextValueReader which will extract values from an IEnumerable<string>.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

ToValueReader<TSource> Generic Method

Creates a Cadenza.IO.EnumerableValueReader which will extract values from an IEnumerable<TSource>.

[System.CLSCompliant(false)]
public static Cadenza.IO.EnumerableValueReader<TSource> ToValueReader<TSource> (this IEnumerable<TSource> self)

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<TSource> containing elements to read values from.

Returns

A Cadenza.IO.EnumerableValueReader which will extract values from an IEnumerable<TSource>.

Exceptions

Type Reason
ArgumentNullException self is null.
ArgumentNullException self is null.

Remarks

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

TrailingSegments<TSource> Generic Method

Creates a IEnumerable<IEnumerable<TSource>> containing all final segments of self, longest first.

public static IEnumerable<IEnumerable<TSource>> TrailingSegments<TSource> (this IEnumerable<TSource> self)

See Also

EnumerableCoda.InitialSegments``1(IEnumerable<``0>)

Type Parameters

TSource
The type of element in the sequence self.

Parameters

self
A IEnumerable<TSource> containing the sequence for which to return the trailing segments.

Returns

A IEnumerable<IEnumerable<TSource>> containing all final segments of self, longest first.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

A "final segment" is the list of TSource values following the "current" index, in which the current index starts at the start of self and increments until the end of self.

C# Example
IEnumerable<IEnumerable<char>> e = "abc".TrailingSegments ();
var l = e.ToList ();
Assert.AreEqual (4, l.Count);
AssertAreSame (new[]{'a', 'b', 'c'},  l [0]);
AssertAreSame (new[]{'a', 'b'},       l [1]);
AssertAreSame (new[]{'a'},            l [2]);
AssertAreSame (new char[]{},          l [3]);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Transpose<TSource> Generic Method

Transposes self, so that rows become columns and columns become rows in the returned IEnumerable<IEnumerable<TSource>>.

public static IEnumerable<IEnumerable<TSource>> Transpose<TSource> (this IEnumerable<IEnumerable<TSource>> self)

Type Parameters

TSource
The type of element to return.

Parameters

self
A IEnumerable<IEnumerable<TSource>> containing rows and columns to transpose.

Returns

A IEnumerable<IEnumerable<TSource>>, in which columns and rows are transposed.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

If each row has a different number of elements, then the returned IEnumerable<IEnumerable<TSource>>. will have as many rows as the longest number of columns within self, and any rows with fewer than the maximum number of input columns are "skipped" when an input column index exceeds the length of that row.

C# Example
IEnumerable<IEnumerable<int>> a = new int[][]{
	new int[]{1, 2, 3},
	new int[]{4, 5, 6},
};
IEnumerable<IEnumerable<int>> b = a.Transpose ();
List<List<int>> c = b.ToList ();
Assert.AreEqual (3, c.Count);
Assert.AreEqual (2, c [0].Count);
Assert.AreEqual (2, c [1].Count);
Assert.AreEqual (2, c [2].Count);
Assert.AreEqual (1, c [0][0]);
Assert.AreEqual (4, c [0][1]);
Assert.AreEqual (2, c [1][0]);
Assert.AreEqual (5, c [1][1]);
Assert.AreEqual (3, c [2][0]);
Assert.AreEqual (6, c [2][1]);

// Test non-"rectangular" array
a = new int[][]{
	new int[]{1, 2},
	new int[]{3},
	new int[]{4, 5},
};
b = a.Transpose ();
Assert.AreEqual (2, b.Count ());
Assert.IsTrue (new[]{1, 3, 4}.SequenceEqual (b.ElementAt (0)));
Assert.IsTrue (new[]{2, 5}.SequenceEqual (b.ElementAt (1)));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

TryGetFirst<TSource> Generic Method

Attempts to obtain the first element in the sequence.

public static bool TryGetFirst<TSource> (this IEnumerable<TSource> self, out TSource first)

Type Parameters

TSource
The type of the elements in self.

Parameters

self
An IEnumerable<TSource> containing the sequence of elements to extract the first element from.
first
When this method returns, contains a TSource which contains either the first element within self (if the return value is true), or will contain default(TSource).

Returns

true if self contains elements and first contains the value of the first element; otherwise, false.

Remarks

Note: Use this method instead of System.Linq.Enumerable.FirstOrDefault`1(IEnumerable<``0>) when one of the elements in the sequence may be default(TSource), thus making it impossible to tell if default(TSource), was returned because no matching element was found or because default(TSource), was the matching element).
C# Example
var seq = new int[]{0, 1, 2};
int first;

Assert.IsTrue (seq.TryGetFirst (out first));
Assert.IsTrue (0 == first);

seq = new int[]{};
Assert.IsFalse (seq.TryGetFirst (out first));
Assert.IsTrue (0 == first);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

TryGetFirst<TSource> Generic Method

Attempts to obtain the first element in the sequence that satisfies the specified condition.

public static bool TryGetFirst<TSource> (this IEnumerable<TSource> self, Func<TSource, bool> predicate, out TSource first)

Type Parameters

TSource
The type of the elements in self.

Parameters

self
An IEnumerable<TSource> containing the sequence of elements to extract the first element from.
predicate
A Func<TSource, bool> which is tested against each element within self.
first
When this method returns, contains a TSource which contains either the first element for which predicate returned true (if the return value is true), or will contain default(TSource).

Returns

true if self contains elements and predicate returned true for one of those elements and first contains the value of the first matching value; otherwise, false.

Remarks

Note: Use this method instead of System.Linq.Enumerable.FirstOrDefault`1(IEnumerable<``0>, Func<``0, bool>) when one of the elements in the sequence may be default(TSource), thus making it impossible to tell if default(TSource), was returned because no matching element was found or because default(TSource), was the matching element).
C# Example
var seq = new int[]{0, 1, 2};
int first;

Assert.IsTrue (seq.TryGetFirst (v => v.IsOdd (), out first));
Assert.IsTrue (1 == first);

Assert.IsTrue (seq.TryGetFirst (v => v.IsEven (), out first));
Assert.IsTrue (0 == first);

Assert.IsFalse (seq.TryGetFirst (v => v == 5, out first));
Assert.IsTrue (0 == first);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Unzip<T1,T2> Generic Method

Converts an IEnumerable<Cadenza.Tuple<T1, T2>> into a tuple of lists, one for each Cadenza.Tuple<T1, T2> element.

See Also

EnumerableCoda.Zip``2(IEnumerable<``0>, IEnumerable<``1>)

Type Parameters

T1
The type of the first sequence to return.
T2
The type of the second sequence to return.

Parameters

self
A IEnumerable<Cadenza.Tuple<T1, T2>> to split up into separate lists.

Returns

An Cadenza.Tuple<IEnumerable<T1>, IEnumerable<T2>> containing the appropriate elements from each Cadenza.Tuple<T1, T2>.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

This is analogous to undoing a Zip operation.

C# Example
Assert.AreEqual ("1,2|3,4",
		new[]{1,2}.Zip (new[]{3,4,5}).Unzip ()
		.Aggregate ((a, b) => a.Implode (",") + "|" + b.Implode (",")));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Unzip<T1,T2,T3> Generic Method

Converts an IEnumerable<Cadenza.Tuple<T1, T2, T3>> into a tuple of lists, one for each Cadenza.Tuple<T1, T2, T3> element.

See Also

EnumerableCoda.Zip``3(IEnumerable<``0>, IEnumerable<``1>, IEnumerable<``2>)

Type Parameters

T1
The type of the first sequence to return.
T2
The type of the second sequence to return.
T3
The type of the third sequence to return.

Parameters

self
A IEnumerable<Cadenza.Tuple<T1, T2, T3>> to split up into separate lists.

Returns

An Cadenza.Tuple<IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>> containing the appropriate elements from each Cadenza.Tuple<T1, T2, T3>.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

This is analogous to undoing a Zip operation.

C# Example
Assert.AreEqual ("1,2|3,4|5,6",
		new[]{1,2}.Zip (new[]{3,4,5}, new[]{5,6}).Unzip ()
		.Aggregate ((a, b, c) => a.Implode (",") + "|" + b.Implode (",") + "|" + c.Implode (",")));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Unzip<T1,T2,T3,T4> Generic Method

Converts an IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>> into a tuple of lists, one for each Cadenza.Tuple<T1, T2, T3, T4> element.

See Also

EnumerableCoda.Zip``4(IEnumerable<``0>, IEnumerable<``1>, IEnumerable<``2>, IEnumerable<``3>)

Type Parameters

T1
The type of the first sequence to return.
T2
The type of the second sequence to return.
T3
The type of the third sequence to return.
T4
The type of the fourth sequence to return.

Parameters

self
A IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>> to split up into separate lists.

Returns

An Cadenza.Tuple<IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>> containing the appropriate elements from each Cadenza.Tuple<T1, T2, T3, T4>.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

This is analogous to undoing a Zip operation.

C# Example
Assert.AreEqual ("1,2|3,4|5,6|7,8",
		new[]{1,2}.Zip (new[]{3,4,5,6}, new[]{5,6,7}, new[]{7,8}).Unzip ()
		.Aggregate ((a, b, c, d) => a.Implode (",") + "|" + b.Implode (",") + "|" + c.Implode (",") + "|" + d.Implode (",")));

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Zip<T1,T2> Generic Method

Creates and returns an IEnumerable<Cadenza.Tuple<T1, T2>> containing the corresponding items from self and source2.

public static IEnumerable<Cadenza.Tuple<T1, T2>> Zip<T1, T2> (this IEnumerable<T1> self, IEnumerable<T2> source2)

See Also

EnumerableCoda.SelectFromEach``3(IEnumerable<``0>, IEnumerable<``1>, Func<``0, ``1, ``2>)
EnumerableCoda.Unzip``2(IEnumerable<Cadenza.Tuple<``0, ``1>>)

Type Parameters

T1
The type of elements in the first list.
T2
The type of elements in the second list.

Parameters

self
A IEnumerable<T1> containing elements from the first list.
source2
A IEnumerable<T2> containing elements from the second list.

Returns

An IEnumerable<Cadenza.Tuple<T1, T2>> containing the corresponding items from self and source2.

Exceptions

Type Reason
ArgumentNullException self or source2 is null.

Remarks

Returns an IEnumerable<Cadenza.Tuple<T1, T2>> where each Cadenza.Tuple<T1, T2> contains an element from self and source2 with the same element index.

The number of items in the list returned is equal to the shorter of self and source2.

C# Example
Assert.AreEqual ("1,5|2,4|",
		new[]{1,2}.Zip (new[]{5,4,3})
		.Aggregate (new StringBuilder(), 
			(b, e) => b.AppendFormat ("{0},{1}|", e.Item1, e.Item2)).ToString ());
Assert.AreEqual ("",
		new int[]{}.Zip (new[]{5,4,3})
		.Aggregate (new StringBuilder(), 
			(b, e) => b.AppendFormat ("{0},{1}|", e.Item1, e.Item2)).ToString ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Zip<T1,T2,T3> Generic Method

Creates and returns an IEnumerable<Cadenza.Tuple<T1, T2, T3>> containing the corresponding items from self, source2, and source3.

public static IEnumerable<Cadenza.Tuple<T1, T2, T3>> Zip<T1, T2, T3> (this IEnumerable<T1> self, IEnumerable<T2> source2, IEnumerable<T3> source3)

See Also

EnumerableCoda.SelectFromEach``4(IEnumerable<``0>, IEnumerable<``1>, IEnumerable<``2>, Func<``0, ``1, ``2, ``3>)
EnumerableCoda.Unzip``3(IEnumerable<Cadenza.Tuple<``0, ``1, ``2>>)

Type Parameters

T1
The type of elements in the first list.
T2
The type of elements in the second list.
T3
The type of elements in the third list.

Parameters

self
A IEnumerable<T1> containing elements from the first list.
source2
A IEnumerable<T2> containing elements from the second list.
source3
A IEnumerable<T3> containing elements from the third list.

Returns

An IEnumerable<Cadenza.Tuple<T1, T2>> containing the corresponding items from self, source2, and source3.

Exceptions

Type Reason
ArgumentNullException self, source2, or source3 is null.

Remarks

Returns an IEnumerable<Cadenza.Tuple<T1, T2>> where each Cadenza.Tuple<T1, T2> contains an element from each of self, source2, and source3 with the same element index.

The number of items in the list returned is equal to the shorter of self, source2, and source3.

C# Example
Assert.AreEqual ("1,3,5|2,4,6|",
		new[]{1,2}.Zip (new[]{3,4,5,6}, new[]{5,6,7})
		.Aggregate (new StringBuilder(), 
			(b, e) => b.AppendFormat ("{0},{1},{2}|", e.Item1, e.Item2, e.Item3)).ToString ());
Assert.AreEqual ("",
		new int[]{}.Zip (new[]{5,4,3}, new[]{1,2,3})
		.Aggregate (new StringBuilder(), 
			(b, e) => b.AppendFormat ("{0},{1},{2}|", e.Item1, e.Item2, e.Item3)).ToString ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Zip<T1,T2,T3,T4> Generic Method

Creates and returns an IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>> containing the corresponding items from self, source2, source3, and source4.

public static IEnumerable<Cadenza.Tuple<T1, T2, T3, T4>> Zip<T1, T2, T3, T4> (this IEnumerable<T1> self, IEnumerable<T2> source2, IEnumerable<T3> source3, IEnumerable<T4> source4)

See Also

EnumerableCoda.SelectFromEach``5(IEnumerable<``0>, IEnumerable<``1>, IEnumerable<``2>, IEnumerable<``3>, Func<``0, ``1, ``2, ``3, ``4>)
EnumerableCoda.Unzip``4(IEnumerable<Cadenza.Tuple<``0, ``1, ``2, ``3>>)

Type Parameters

T1
The type of elements in the first list.
T2
The type of elements in the second list.
T3
The type of elements in the third list.
T4
The type of elements in the fourth list.

Parameters

self
A IEnumerable<T1> containing elements from the first list.
source2
A IEnumerable<T2> containing elements from the second list.
source3
A IEnumerable<T3> containing elements from the third list.
source4
A IEnumerable<T4> containing elements from the fourth list.

Returns

An IEnumerable<Cadenza.Tuple<T1, T2>> containing the corresponding items from self, source2, source3, and source4.

Exceptions

Type Reason
ArgumentNullException self, source2, source3, or source4 is null.

Remarks

Returns an IEnumerable<Cadenza.Tuple<T1, T2>> where each Cadenza.Tuple<T1, T2> contains an element from each of self, source2, source3, and source4 with the same element index.

The number of items in the list returned is equal to the shorter of self, source2, source3, and source4.

C# Example
Assert.AreEqual ("1,3,5,7|2,4,6,8|",
		new[]{1,2}.Zip (new[]{3,4,5,6}, new[]{5,6,7}, new[]{7,8})
		.Aggregate (new StringBuilder(), 
			(b, e) => b.AppendFormat ("{0},{1},{2},{3}|", e.Item1, e.Item2, e.Item3, e.Item4)).ToString ());
Assert.AreEqual ("",
		new int[]{}.Zip (new[]{3,4,5,6}, new[]{5,6,7}, new[]{7,8})
		.Aggregate (new StringBuilder(), 
			(b, e) => b.AppendFormat ("{0},{1},{2},{3}|", e.Item1, e.Item2, e.Item3, e.Item4)).ToString ());

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0