Cadenza : Cadenza Namespace

JaggedArrayCoda Class

Extension methods for jagged arrays.

public static class JaggedArrayCoda

Remarks

A jagged array is a type like int[][].

Requirements

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

Members

See Also: Inherited members from object.

Public Methods

static
Rows<TSource> (this TSource[][]) : IEnumerable<IEnumerable<TSource>>
Converts a jagged array into an IEnumerable<IEnumerable<TSource>>.

Member Details

Rows<TSource> Generic Method

Converts a jagged array into an IEnumerable<IEnumerable<TSource>>.

public static IEnumerable<IEnumerable<TSource>> Rows<TSource> (this TSource[][] self)

Type Parameters

TSource
The type of elements within the jagged array.

Parameters

self
A jagged array of TSource elements.

Returns

An IEnumerable<IEnumerable<TSource>> of each element within self in row-major order.

Exceptions

Type Reason
ArgumentNullException self is null.

Remarks

This is particularly useful for transposing jagged arrays, as it can be used with IEnumerableCoda.Transpose``1(IEnumerable<IEnumerable<``0>>).

C# Example
int[][] s = new []{
	new[]{1, 2, 3},
	new[]{4, 5, 6},
	new[]{7, 8, 9},
};
IEnumerable<IEnumerable<int>> r = s.Rows();
Assert.AreEqual (3, r.Count ());

Assert.IsTrue (new[]{1,2,3}.SequenceEqual (r.ElementAt (0)));
Assert.IsTrue (new[]{4,5,6}.SequenceEqual (r.ElementAt (1)));
Assert.IsTrue (new[]{7,8,9}.SequenceEqual (r.ElementAt (2)));

Requirements

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