budul.SetExtensions
1.17.0
dotnet add package budul.SetExtensions --version 1.17.0
NuGet\Install-Package budul.SetExtensions -Version 1.17.0
<PackageReference Include="budul.SetExtensions" Version="1.17.0" />
<PackageVersion Include="budul.SetExtensions" Version="1.17.0" />
<PackageReference Include="budul.SetExtensions" />
paket add budul.SetExtensions --version 1.17.0
#r "nuget: budul.SetExtensions, 1.17.0"
#:package budul.SetExtensions@1.17.0
#addin nuget:?package=budul.SetExtensions&version=1.17.0
#tool nuget:?package=budul.SetExtensions&version=1.17.0
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 anIEnumerable<T>representing one combination (one element from each input sequence).IsSubSetOf<T>(this IEnumerable<T> current, IEnumerable<T> other)
Tests whethercurrentis a multiset subset ofother. Duplicate counts are respected (uses lookups). Note: the implementation returnsfalseif either sequence is null or empty.IsSubSetOfOrOther<T>(this IEnumerable<T> current, IEnumerable<T> other)
Returns true if eithercurrentis a multiset subset ofotheror vice‑versa. Both sequences must be non‑empty for this method to returntrue.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 byCurrent(viakeySelector) and then groups by best overlaps of previous/next elements. The optionalmergeEndsparameter (defaultfalse) controls whether sequence ends may be treated as compatible when comparing neighbors. Missing neighbors are represented bydefault(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 | Versions 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. |
-
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 |