budul.SetExtensions 1.14.0

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

SetExtensions

Lightweight C# extension methods for working with collections of sets (IEnumerable<IEnumerable<T>>).
Supports .NET Standard 2.0 / 2.1 and .NET 7 / 8.

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,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 net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net7.0

    • No dependencies.
  • 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
1.14.0 399 11/20/2025
1.13.0 393 11/19/2025
1.12.0 391 11/18/2025
1.11.0 393 11/18/2025
1.10.0 363 6/29/2023
1.9.1 544 8/23/2022
1.9.0 535 8/23/2022
1.8.1 574 6/13/2022
1.8.0 576 6/13/2022
1.7.0 570 5/29/2021
1.6.0 613 10/11/2020
1.5.0 655 5/28/2020
1.4.0 654 5/28/2020
1.3.0 632 5/5/2020
1.2.0 628 5/5/2020
1.1.0 644 5/5/2020
1.0.0 639 5/5/2020