collection-iterable-methods
2.0.0
See the version list below for details.
dotnet add package collection-iterable-methods --version 2.0.0
NuGet\Install-Package collection-iterable-methods -Version 2.0.0
<PackageReference Include="collection-iterable-methods" Version="2.0.0" />
<PackageVersion Include="collection-iterable-methods" Version="2.0.0" />
<PackageReference Include="collection-iterable-methods" />
paket add collection-iterable-methods --version 2.0.0
#r "nuget: collection-iterable-methods, 2.0.0"
#:package collection-iterable-methods@2.0.0
#addin nuget:?package=collection-iterable-methods&version=2.0.0
#tool nuget:?package=collection-iterable-methods&version=2.0.0
collection-iterable-methods
Node-style collection names for .NET 8, backed by LINQ and specialized paths where measurements justify them. Version 2.0.0 includes a deliberate Map API change; see the migration notes below.
using CollectionIterable;
using CollectionIterableAsync;
var numbers = new[] { 1, 2, 3, 4, 5 };
var evens = numbers.Filter(number => number % 2 == 0);
var labels = numbers.Map(number => $"Item {number}");
var indexed = numbers.Map((number, index) => $"{index}: {number}");
var sum = numbers.Reduce((total, number) => total + number, 0);
var sorted = numbers.SortCollection(number => number);
var completed = await numbers.FilterAsync(number => number > 2);
Contracts
| Methods | Execution / ordering |
|---|---|
| Filter, Map | Lazy, ordered, replayable when the source is replayable |
| Slice | Lazy, ordered, start inclusive/end exclusive; negative start rejected |
| Reduce, ForEach, ToRecord, SortCollection | Complete synchronously |
| Concat | Arrays/collections copied immediately; general enumerables lazy |
| FilterAsync, ConcatAsync, ForEachAsync | Synchronous callbacks/work run on Task.Run; complete before await returns |
| FilterParallel, FilterParallelAsync | Complete before return/await; unordered output |
| ForEachParallel, ForEachParallelAsync | Concurrent callbacks; caller must synchronize shared mutable state |
| SortCollectionParallel | Sorted output; equal-key order unspecified; small inputs may sort sequentially |
| ToDictionaryParallel | Concurrent callbacks; duplicate-key winner unspecified; returns a ConcurrentDictionary through IDictionary |
Both indexed and non-indexed callbacks are supported for ordinary transformations. Map supports different input/output types. ToRecord rejects duplicate keys. Sorts preserve source contents and are not stable for equal keys. Selectors should be pure.
Async callbacks remain synchronous delegates: these methods are CPU offloading helpers, not async-I/O pipelines. Do not pass async-void lambdas. Use native async APIs for I/O and async streams. Cancellation is cooperative; running callbacks cannot be forcibly interrupted. Parallel options are copied, not mutated; either supplied token can cancel the operation. Default maximum parallelism is five.
The legacy void CollectionIterableAsync.ForeachParallel overloads remain but are obsolete. Use ForEachParallelAsync and await it to observe completion and errors.
Migration from 1.0.2
- Rebuild consumers: Map now uses
<TSource,TResult>. Inferred calls such as.Map(x => x + 1)remain valid. Explicit.Map<int>(...)becomes.Map<int,int>(...)or omits type arguments. - FilterAsync and general-enumerable ConcatAsync now materialize before completing; work/errors no longer wait until result enumeration. This changes timing and memory lifetime.
- Registered parallel cancellation raises OperationCanceledException directly instead of the previous manual-check AggregateException. Callback failures remain observable; dictionary merge/key failures may now surface directly after callback processing.
- Framework-backed methods use framework argument validation; sorts cache keys and can change comparator exception wrapping, null-key handling and tie order.
Performance and scope
Before/after report includes 150 workloads, repeated timings, allocation tradeoffs, tests and reproduction commands. Gains depend on method/input. Async or parallel execution is not automatically faster. Additional key/batch buffers trade memory for speed.
This is an in-memory IEnumerable library, not a replacement for all LINQ. Results can be chained with LINQ. Use Queryable directly for database expression trees to retain provider translation.
dotnet test Performance/Tests/Tests.csproj -c Release
DOTNET_TieredCompilation=0 dotnet run --project Performance/Benchmarks.csproj -c Release
MIT license; see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.