Class ArrayExtensions
Provides extension methods for arrays.
Namespace: Celestial.UIToolkit.Extensions
Assembly: Celestial.UIToolkit.Core.dll
Syntax
public static class ArrayExtensions
Methods
| Improve this Doc View SourceGetGroupSegments<T>(T[], Func<T, Boolean>)
Returns a set of segments which identify certain groups in an array.
Declaration
public static IEnumerable<ArraySegment<T>> GetGroupSegments<T>(this T[] array, Func<T, bool> isElementPartOfSegment)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to be split into segments. |
Func<T, Boolean> | isElementPartOfSegment | A function which is used to determine if an element belongs to the segment groups. |
Returns
Type | Description |
---|---|
IEnumerable<ArraySegment<T>> | The set of array segments. |
Type Parameters
Name | Description |
---|---|
T | The array's type. |
Examples
Say that you have an array of numbers and want to retrieve groups of even numbers. This method will return each group segment which satisfies that conditions.
For example:
[1, 2, 4, 6, 3, 5, 2, 9, 10, 12] [^ ^ ^] [^] [^ ^] ^= 3 segments of even numbers.