collection-iterable-methods 2.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package collection-iterable-methods --version 2.0.2
                    
NuGet\Install-Package collection-iterable-methods -Version 2.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="collection-iterable-methods" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="collection-iterable-methods" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="collection-iterable-methods" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add collection-iterable-methods --version 2.0.2
                    
#r "nuget: collection-iterable-methods, 2.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package collection-iterable-methods@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=collection-iterable-methods&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=collection-iterable-methods&version=2.0.2
                    
Install as a Cake Tool

collection-iterable-methods

Write expressive C#. Get more from every collection.

NuGet Target framework License: MIT

Bring the simplicity of Filter, Map, and Reduce to .NET 8. Turn arrays, lists, and enumerables into readable pipelines with automatic type inference, LINQ integration, and powerful async and parallel operations. Zero package dependencies.

Explore the website · Install from NuGet · API guide · About the developer

Why use it?

  • Express the transformation. Filter, map, slice, sort, and reduce with familiar names and concise, chainable code.
  • Keep the power of C#. Transform between types with full inference, use indexed callbacks, and compose with LINQ.
  • Put concurrency to work. Await CPU operations, run callbacks in parallel, and configure cancellation and concurrency in one place.
  • Benefit from optimized paths. LINQ-backed transformations, bounded streaming slices, and cached sort keys improve core collection operations.

Faster where it counts

Selected operations show substantial improvements in the recorded 2.0 candidate vs. 1.0.2 source benchmarks:

Operation Measured speedup Repeat run
Map 2.31–9.89× 2.14–10.29×
Filter 1.35–4.61× 1.38–4.63×
Slice 1.59–12.43× 1.68–12.40×
ForEach 1.49–3.94× 1.64–3.78×

Ranges cover the tested inputs for each operation. Explore all 156 workloads, methodology, and allocation measurements in the full benchmark report.

Install

Requires a .NET 8-compatible project. Current stable release: 2.0.2.

dotnet add package collection-iterable-methods --version 2.0.2

A first transformation

using CollectionIterable;

var numbers = new[] { 1, 2, 3, 4, 5, 6 };
var labels = numbers
    .Filter(number => number % 2 == 0)
    .Map(number => $"Item {number}")
    .ToArray();

// ["Item 2", "Item 4", "Item 6"]

var total = numbers.Reduce((sum, number) => sum + number, 0); // 21
var middle = numbers.Slice(1, 4).ToArray();                   // [2, 3, 4]
var indexed = numbers.Map((number, index) => $"{index}: {number}");

Filter, Map, and Slice are lazy. Enumerate to execute them; call ToArray() to capture a result. Map infers both the input and output type. Ordinary LINQ methods can follow these operations.

Choose an execution model

Use case Namespace Start with
Expressive collection pipelines CollectionIterable Filter, Map, Reduce, Slice
Awaitable CPU operations CollectionIterableAsync FilterAsync, ForEachAsync
Concurrent CPU callbacks CollectionIterableParallel FilterParallel, ForEachParallel
Cancellation and concurrency options CollectionIterableUtils IIterableOptions

Put async to work

using CollectionIterableAsync;

var evens = await new[] { 1, 2, 3, 4 }.FilterAsync(n => n % 2 == 0);
// Work is complete; evens contains 2, 4.

Take control of parallel execution

using CollectionIterableParallel;
using CollectionIterableUtils;

using var cancellation = new CancellationTokenSource();
var options = new IIterableOptions
{
    parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 4 },
    cancellationToken = cancellation.Token
};
var evens = new[] { 1, 2, 3, 4 }.FilterParallel(n => n % 2 == 0, options);
// Contains 2, 4. Order is unspecified.

Everything you need to keep building

Explore the API and migration guide for execution behavior, ordering, cancellation, and upgrading from 1.0.2. Async methods accept synchronous CPU callbacks; use native async APIs for I/O. Parallel filter results are unordered.

Want to contribute? See the development guide for builds, tests, benchmarks, and website deployment.

Created by Johnny Quesada. Open source under the MIT license.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
2.0.3 136 9/21/2026
2.0.2 105 9/21/2026
2.0.1 101 9/21/2026
2.0.0 100 9/21/2026
2.0.0-preview.1 80 9/21/2026
1.0.2 388 12/23/2023
1.0.1 246 12/23/2023
1.0.0 229 12/23/2023