budul.SetExtensions 1.17.0

dotnet add package budul.SetExtensions --version 1.17.0
                    
NuGet\Install-Package budul.SetExtensions -Version 1.17.0
                    
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="budul.SetExtensions" Version="1.17.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="budul.SetExtensions" Version="1.17.0" />
                    
Directory.Packages.props
<PackageReference Include="budul.SetExtensions" />
                    
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 budul.SetExtensions --version 1.17.0
                    
#r "nuget: budul.SetExtensions, 1.17.0"
                    
#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 budul.SetExtensions@1.17.0
                    
#: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=budul.SetExtensions&version=1.17.0
                    
Install as a Cake Addin
#tool nuget:?package=budul.SetExtensions&version=1.17.0
                    
Install as a Cake Tool

SetExtensions

Lightweight C# extension methods for working with collections of sets (IEnumerable<IEnumerable<T>>).
Supports .NET 10.

Quick overview

Public extension methods are defined in SetExtensions.Extensions:

  • CartesianProduct<T>(this IEnumerable<IEnumerable<T>> sequences)
    Produces the Cartesian product of a sequence of sequences. Each yielded item is an IEnumerable<T> representing one combination (one element from each input sequence).

  • IsSubSetOf<T>(this IEnumerable<T> current, IEnumerable<T> other)
    Tests whether current is a multiset subset of other. Duplicate counts are respected (uses lookups). Note: the implementation returns false if either sequence is null or empty.

  • IsSubSetOfOrOther<T>(this IEnumerable<T> current, IEnumerable<T> other)
    Returns true if either current is a multiset subset of other or vice‑versa. Both sequences must be non‑empty for this method to return true.

  • Segmented<T>(this IEnumerable<IEnumerable<T>> sequences)
    Splits the provided sets into non‑intersecting segments (disjoint groups). Empty or null inner sequences are ignored. Duplicate groups are collapsed and element multiplicity inside groups is normalized (sets).

  • ToNeighborGroups<T, TKey>(this IEnumerable<IEnumerable<T>> sequences, Func<T, TKey> keySelector, bool mergeEnds = false)
    Produces groups of neighbor triplets (Previous, Current, Next) from the sequences using a combined strategy that first clusters by Current (via keySelector) and then groups by best overlaps of previous/next elements. The optional mergeEnds parameter (default false) controls whether sequence ends may be treated as compatible when comparing neighbors. Missing neighbors are represented by default(T).

  • Transponded<T>(this IEnumerable<IEnumerable<T>> sets)
    Transposes the collection of sequences: returns the i-th elements across all input sequences as the i-th output sequence (matrix transpose). If an input sequence is shorter, default(T) is used for missing positions. The implementation materializes inner sequences to arrays for performance.

Small usage examples

using SetExtensions;
// Cartesian product 
var sets = new[] { new[] {1,2}, new[] {3,4} }; 
var product = sets.CartesianProduct(); 
// yields sequences: [1,3], [1,4], [2,3], [2,4]

// Subset 
var a = new[] {1,1,2}; 
var b = new[] {1,1,2,3}; 
var isSubset = a.IsSubSetOf(b); 
// true

// Segmented 
var setsForSeg = new[] { new[] {1,1,2}, new[] {1,1,2,3} }; 
var segments = setsForSeg.Segmented(); 
// yields disjoint groups covering values, e.g. [1,2], [3] (order not guaranteed)

// Transpose 
var rows = new[] { new[] { "a","b" }, new[] { "c","d" } }; 
var cols = rows.Transponded(); 
// yields ["a","c"], ["b","d"]

// Neighbor groups (example uses string key) 
var sequences = new[] { new[] { "a", "b" }, new[] { "a", "b", "c" } , new[] { "b", "c" } }; 
var groups = sequences.ToNeighborGroups(s => s); 
// yields [(null, "a", "b"), (null, "a", "b")], [("a", "b", null), ("a", "b", "c"), (null, "b", "c")], [("b", "c", null), ("b", "c", null)]

Notes

License and contribution info: refer to the repository at https://github.com/budul100/SetExtensions.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.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
1.17.0 102 11/26/2026
1.15.0 193 6/12/2026
1.14.0 509 11/20/2025
1.13.0 478 11/19/2025
1.12.0 476 11/18/2025
1.11.0 478 11/18/2025
1.10.0 432 6/29/2023
1.9.1 612 8/23/2022
1.9.0 595 8/23/2022
1.8.1 636 6/13/2022
1.8.0 651 6/13/2022
1.7.0 637 5/29/2021
1.6.0 685 10/11/2020
1.5.0 723 5/28/2020
1.4.0 722 5/28/2020
1.3.0 697 5/5/2020
1.2.0 702 5/5/2020
1.1.0 722 5/5/2020
1.0.0 704 5/5/2020