Click or drag to resize

Version History

KwCombinatorics version 1.2 (2009-03-03)
  • Implements generic IEquatable interface.

  • Implements proper null tests for comparison operators.

KwCombinatorics version 1.3 (2012-01-05)
  • Updates build environment to Visual Studio 2010.

KwCombinatorics version 1.4 (2012-03-23)
  • Adds increment, decrement operators for all classes.

  • Fixes bugs on empty sequences.

  • Renames many parameters.

  • Adds minor optimizations.

KwCombinatorics version 2.2 (2012-04-01)
  • Adds Multicombination.GetRowsForPicks (startPicks, stopPicks).

  • Adds CopyTo (array) to all combinatorics.

  • Removes Multicombination.GetRows (picks, startRank).

KwCombinatorics version 2.3 (2012-04-17)
  • Adds Permutation.Backtrack method.

  • Multicombination ranking constructor accepts unsorted data.

  • Combination ranking constructor accepts unsorted data.

  • Fixes numeric overflow bug in Combination.Rank setter.

  • Fixes missing numeric overflow checks in Product constructors.

  • Fixes missing bounds checks in Product ranking constructor.

  • Removes increment and decrement operators.

KwCombinatorics version 2.4 (2012-07-01)
  • Optimizes Combination.Rank setter.

  • Optimizes Multicombination.Rank setter.

  • Adds methods Combinatoric.BinomialCoefficient, Combinatoric.Factorial.

KwCombinatorics version 4 (2012-11-14)

This release makes several changes to the Permutation class to add support for plain changes. There are also several breaking changes to improve API readability.

  • Adds Permutation.Choices property to support k-permutations.

  • Adds Permutation constructors to support k-permutations.

  • Adds property Permutation.PlainChange.

  • Adds property Permutation.Swaps.

  • Adds method Permutation.GetRowsForAllPicks.

  • Adds method Permutation.GetRowsOfPlainChanges.

  • Renames all Height properties to RowCount.

  • Renames Permutation.Width to Picks.

  • Renames Permutation.MaxWidth to MaxChoices.

  • Renames Permutation.GetRowsForAllWidths to GetRowsForAllChoices.

  • Removes Permutation (int, long) constructor.

  • Removes ICloneable base class and Clone methods from all combinatorics.

KaosCombinatorics version 5 (2017-04-14)

This release updates tooling to 2017. The new .NET Standard has been embraced for compatibility and future-proofing. Development now requires Visual Studio 2017 with the repository changed to Git. Binary now hosted at NuGet.org.

  • Renames namespace from Kw to Kaos.

  • Changes binary to .NET Standard 1.0 multitargeted to .NET 3.5, .NET 4.0.

  • Updates build environment to Visual Studio 2017.

KaosCombinatorics version 6 (2020-01-01)

Summary

  • Optimizes Permutation class for speed and allocations.

  • Changes Permutation comparisons to include the Choices property.

  • Changes iterator behavior to produce consistent operand side effects.

  • Changes thrown exceptions.

  • Applies strong name to assembly.

Details

Optimize Permutation class for speed and allocations

The Permutation class has seen the elimination of some temporary memory allocations in constructors taking int[], the Rank setter, and backtracking. This change also comes with slight performance improvements.

Change Permutation comparisons to include the Choices property

Previously, comparison of permutations did not compare the Choices property as in this snippet:

C#
Console.WriteLine (new Permutation(choices:4,picks:3,rank:0)==new Permutation(choices:5,picks:3,rank:0));
/* Output: true */

This issue has been fixed and this example now correctly returns false.

Change iterator behavior to produce consistent operand side effects

Previous versions of iterators produced inconsistent side affects to their operands. New behavior is to synchronize the operand to the values yielded and restore their operand to its original state after the iteration is complete.

All iterators are affected:

  • Combination.GetRows, Combination.GetRowsForAllPicks

  • Multicombination.GetRows, Multicombination.GetRowsForPicks

  • Permutation.GetRows, Permutation.GetRowsForAllChoices, Permutation.GetRowsForAllPicks, Permutation.GetRowsOfPlainChanges

  • Product.GetRows

There is no impact for the typical scenario where the operand is not directly accessible as in this snippet:

C#
foreach (var cn in new Combination (choices:3, picks:2).GetRowsForAllPicks())
    Console.WriteLine (cn);

/* Output:

{ 0 }
{ 1 }
{ 2 }
{ 0, 1 }
{ 0, 2 }
{ 1, 2 }*/

This change only impacts the atypical scenario where the operand is accessible independent of the yielded result such as in this snippet:

C#
var cn0 = new Combination (choices:3, picks:2);
foreach (var cn in cn0.GetRowsForAllPicks())
    Console.WriteLine ($"cn={cn} cn0={cn0}");
Console.WriteLine ($"After complete, cn0={cn0}");

/* Output:

cn={ 0 } cn0={ 0 }
cn={ 1 } cn0={ 1 }
cn={ 2 } cn0={ 2 }
cn={ 0, 1 } cn0={ 0, 1 }
cn={ 0, 2 } cn0={ 0, 2 }
cn={ 1, 2 } cn0={ 1, 2 }
After complete, cn0={ 0, 1 }*/

Change thrown exceptions

Minor changes have been made to exception throwing in:

  • Methods Permutation.Permute, Product.Permute

  • Constructors Permutation (int[]), Permutation (int[], int)

Where Permute methods threw IndexOutOfRangeException they now throw ArgumentException with a fail fast approach.

Where Permutation constructors taking an element array threw IndexOutOfRangeException they now throw ArgumentException.

Apply strong name to assembly

Strong names signing is necessary for installation into the Global Assembly Cache. As a convenience, an installer has been provided for this purpose.

See Also