Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/list chunk #19

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-devfast-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
buildAndTestFull:
strategy:
matrix:
dotnet-version: ['6.x.x','7.x.x','8.x.x']
runs-on: ubuntu-latest
dotnet-version: ['8.x.x']
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Similar ".TryTo" also exists on ReadOnlySpan<char> and ReadOnlySpan<byt
- myByteArray.DoubleByteCapacity() returns new array with initial bytes but twice the capacity
- myByteArray.CopyToSafe(...) copies bytes to targeted array

#### IEnumerable & IAsyncEnumerable with CancellationToken All the Way
- ForEach, ForEachAsync, ToBlockingEnumerable with CancellationToken
- CancellationToken support for SelectAsync, SkipAsync, TakeAsync, WhereAsync, CountAsync, ToChunksAsync etc.
#### IEnumerable & IAsyncEnumerable with Token All the Way
- ForEach, ForEachAsync, ToBlockingEnumerable with Token
- Token support for SelectAsync, SkipAsync, TakeAsync, WhereAsync, CountAsync, ToChunksAsync etc.
5 changes: 5 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
DevFast.Net.Extensions 0.7.3

1. New feature - Added following new extension methods in DevFast.Net.Extensions.SystemTypes.DataCollections:
- Chunk<T>(this IList<T>, int, CancellationToken, bool)

DevFast.Net.Extensions 0.7.2

1. New feature - With polyfill, increasing library scope for older .Net versions.
Expand Down
67 changes: 67 additions & 0 deletions docs/net6.0/DevFast.Net.Extensions.SystemTypes.DataCollections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#### [DevFast.Net.Extensions](index.md 'index')
### [DevFast.Net.Extensions.SystemTypes](DevFast.Net.Extensions.SystemTypes.md 'DevFast.Net.Extensions.SystemTypes')

## DataCollections Class

Extension methods on various data-collection e.g. [System.Collections.Generic.IList&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1').

```csharp
public static class DataCollections
```
- *Methods*
- **[Chunk&lt;T&gt;(this IList&lt;T&gt;, int, CancellationToken, bool)](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool) 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool)')**

## DataCollections Class

Extension methods on various data-collection e.g. [System.Collections.Generic.IList&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1').

```csharp
public static class DataCollections
```

Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') &#129106; DataCollections
### Methods

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool)'></a>

## DataCollections.Chunk<T>(this IList<T>, int, CancellationToken, bool) Method

Splits the elements of given [list](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).list 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).list') into chunks of [maxSize](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).maxSize 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).maxSize')
WITHOUT re-allocating the memory while observing the provided [token](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).token 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).token').

```csharp
public static System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<T>> Chunk<T>(this System.Collections.Generic.IList<T> list, int maxSize, System.Threading.CancellationToken token, bool observeTokenInChunkEnumeration=false);
```
#### Type parameters

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).T'></a>

`T`
#### Parameters

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).list'></a>

`list` [System.Collections.Generic.IList&lt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1')[T](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).T 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).T')[&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1')

Collection on which chunks will be created.

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).maxSize'></a>

`maxSize` [System.Int32](https://docs.microsoft.com/en-us/dotnet/api/System.Int32 'System.Int32')

Maximum size of a given chunk

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).token'></a>

`token` [System.Threading.CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/System.Threading.CancellationToken 'System.Threading.CancellationToken')

Cancellation token to observe.

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).observeTokenInChunkEnumeration'></a>

`observeTokenInChunkEnumeration` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')

When [true](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/bool 'https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/bool') token cancellation is observed during chunk enumeration (may slow-down enumeration)

#### Returns
[System.Collections.Generic.IEnumerable&lt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')[System.Collections.Generic.IEnumerable&lt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')[T](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).T 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).T')[&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')[&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')
1 change: 1 addition & 0 deletions docs/net6.0/DevFast.Net.Extensions.SystemTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Under this [namespace](https://docs.microsoft.com/en-us/dotnet/csharp/language-r
| Classes | |
| :--- | :--- |
| [ByteArrays](DevFast.Net.Extensions.SystemTypes.ByteArrays.md 'DevFast.Net.Extensions.SystemTypes.ByteArrays') | Extension methods on Array of type [System.Byte](https://docs.microsoft.com/en-us/dotnet/api/System.Byte 'System.Byte'). |
| [DataCollections](DevFast.Net.Extensions.SystemTypes.DataCollections.md 'DevFast.Net.Extensions.SystemTypes.DataCollections') | Extension methods on various data-collection e.g. [System.Collections.Generic.IList&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1'). |
| [Enumerables](DevFast.Net.Extensions.SystemTypes.Enumerables.md 'DevFast.Net.Extensions.SystemTypes.Enumerables') | Extension methods on [System.Collections.Generic.IEnumerable&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1') and [System.Collections.Generic.IAsyncEnumerable&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IAsyncEnumerable-1 'System.Collections.Generic.IAsyncEnumerable`1'). |
| [ReadableSpan](DevFast.Net.Extensions.SystemTypes.ReadableSpan.md 'DevFast.Net.Extensions.SystemTypes.ReadableSpan') | Extension methods on [System.ReadOnlySpan&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.ReadOnlySpan-1 'System.ReadOnlySpan`1'). |
| [Strings](DevFast.Net.Extensions.SystemTypes.Strings.md 'DevFast.Net.Extensions.SystemTypes.Strings') | Extension methods on [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String'). |
67 changes: 67 additions & 0 deletions docs/net8.0/DevFast.Net.Extensions.SystemTypes.DataCollections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#### [DevFast.Net.Extensions](index.md 'index')
### [DevFast.Net.Extensions.SystemTypes](DevFast.Net.Extensions.SystemTypes.md 'DevFast.Net.Extensions.SystemTypes')

## DataCollections Class

Extension methods on various data-collection e.g. [System.Collections.Generic.IList&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1').

```csharp
public static class DataCollections
```
- *Methods*
- **[Chunk&lt;T&gt;(this IList&lt;T&gt;, int, CancellationToken, bool)](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool) 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool)')**

## DataCollections Class

Extension methods on various data-collection e.g. [System.Collections.Generic.IList&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1').

```csharp
public static class DataCollections
```

Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') &#129106; DataCollections
### Methods

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool)'></a>

## DataCollections.Chunk<T>(this IList<T>, int, CancellationToken, bool) Method

Splits the elements of given [list](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).list 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).list') into chunks of [maxSize](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).maxSize 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).maxSize')
WITHOUT re-allocating the memory while observing the provided [token](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).token 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).token').

```csharp
public static System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<T>> Chunk<T>(this System.Collections.Generic.IList<T> list, int maxSize, System.Threading.CancellationToken token, bool observeTokenInChunkEnumeration=false);
```
#### Type parameters

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).T'></a>

`T`
#### Parameters

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).list'></a>

`list` [System.Collections.Generic.IList&lt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1')[T](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).T 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).T')[&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1')

Collection on which chunks will be created.

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).maxSize'></a>

`maxSize` [System.Int32](https://docs.microsoft.com/en-us/dotnet/api/System.Int32 'System.Int32')

Maximum size of a given chunk

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).token'></a>

`token` [System.Threading.CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/System.Threading.CancellationToken 'System.Threading.CancellationToken')

Cancellation token to observe.

<a name='DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).observeTokenInChunkEnumeration'></a>

`observeTokenInChunkEnumeration` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')

When [true](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/bool 'https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/bool') token cancellation is observed during chunk enumeration (may slow-down enumeration)

#### Returns
[System.Collections.Generic.IEnumerable&lt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')[System.Collections.Generic.IEnumerable&lt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')[T](DevFast.Net.Extensions.SystemTypes.DataCollections.md#DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk_T_(thisSystem.Collections.Generic.IList_T_,int,System.Threading.CancellationToken,bool).T 'DevFast.Net.Extensions.SystemTypes.DataCollections.Chunk<T>(this System.Collections.Generic.IList<T>, int, System.Threading.CancellationToken, bool).T')[&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')[&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1')
1 change: 1 addition & 0 deletions docs/net8.0/DevFast.Net.Extensions.SystemTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Under this [namespace](https://docs.microsoft.com/en-us/dotnet/csharp/language-r
| Classes | |
| :--- | :--- |
| [ByteArrays](DevFast.Net.Extensions.SystemTypes.ByteArrays.md 'DevFast.Net.Extensions.SystemTypes.ByteArrays') | Extension methods on Array of type [System.Byte](https://docs.microsoft.com/en-us/dotnet/api/System.Byte 'System.Byte'). |
| [DataCollections](DevFast.Net.Extensions.SystemTypes.DataCollections.md 'DevFast.Net.Extensions.SystemTypes.DataCollections') | Extension methods on various data-collection e.g. [System.Collections.Generic.IList&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IList-1 'System.Collections.Generic.IList`1'). |
| [Enumerables](DevFast.Net.Extensions.SystemTypes.Enumerables.md 'DevFast.Net.Extensions.SystemTypes.Enumerables') | Extension methods on [System.Collections.Generic.IEnumerable&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IEnumerable-1 'System.Collections.Generic.IEnumerable`1') and [System.Collections.Generic.IAsyncEnumerable&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.Collections.Generic.IAsyncEnumerable-1 'System.Collections.Generic.IAsyncEnumerable`1'). |
| [ReadableSpan](DevFast.Net.Extensions.SystemTypes.ReadableSpan.md 'DevFast.Net.Extensions.SystemTypes.ReadableSpan') | Extension methods on [System.ReadOnlySpan&lt;&gt;](https://docs.microsoft.com/en-us/dotnet/api/System.ReadOnlySpan-1 'System.ReadOnlySpan`1'). |
| [Strings](DevFast.Net.Extensions.SystemTypes.Strings.md 'DevFast.Net.Extensions.SystemTypes.Strings') | Extension methods on [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String'). |
2 changes: 1 addition & 1 deletion docs/netstandard2.0/DevFast.Net.Extensions.Etc.Asynchro.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.O
Gets a task that has already completed successfully.

```csharp
public static ValueTask CompletedTask { get; }
public static System.Threading.Tasks.ValueTask CompletedTask { get; }
```

#### Property Value
Expand Down
Loading
Loading