Grouping.Partition Method

Definition

Namespace: Numerics.NET.DataAnalysis
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4

Overload List

Partition(IList<Int32>) Constructs a grouping that represents a collection of non-overlapping chunks of fixed length.
Partition(Int32, Int32) Constructs a grouping that represents a collection of non-overlapping chunks of fixed length.
Partition<TInput>(IList<TInput>, Int32, Boolean, Boolean) Constructs a grouping that represents a collection of non-overlapping chunks of fixed length.

Partition(IList<Int32>)

Constructs a grouping that represents a collection of non-overlapping chunks of fixed length.
C#
public static Grouping<int> Partition(
	IList<int> offsets
)

Parameters

offsets  IList<Int32>
Integer array containing the offsets of the partition boundaries.

Return Value

Grouping<Int32>
A grouping object that represents the chunking.

Exceptions

ArgumentNullException

offsets is null.

ArgumentException

The values in offsets are not in ascending order.

Partition(Int32, Int32)

Constructs a grouping that represents a collection of non-overlapping chunks of fixed length.
C#
public static Grouping<int> Partition(
	int length,
	int size
)

Parameters

length  Int32
The total length of all groups.
size  Int32
The size of each group.

Return Value

Grouping<Int32>
A grouping object that represents the chunking.

Partition<TInput>(IList<TInput>, Int32, Boolean, Boolean)

Constructs a grouping that represents a collection of non-overlapping chunks of fixed length.
C#
public static Grouping<TInput> Partition<TInput>(
	IList<TInput> values,
	int size,
	bool alignToEnd = false,
	bool skipIncomplete = false
)

Parameters

values  IList<TInput>
The collection the grouping is over.
size  Int32
The size of the chunks. Must be greater than zero.
alignToEnd  Boolean  (Optional)
Indicates whether groups should be aligned starting from the end of the index.
skipIncomplete  Boolean  (Optional)
Indicates whether the first or last group should be skipped if it does not have full size.

Type Parameters

TInput

Return Value

Grouping<TInput>
A grouping object that represents the chunking.

Remarks

If alignToEnd is false (the default) then first element of values in each group is used as the key for the group. If alignToEnd is true then the last element of values in each group is used as the key for the group.

Exceptions

ArgumentNullException

values is null.

ArgumentOutOfRangeException

size is less than or equal to zero.

See Also