Click or drag to resize

Product Class

Represents a join of values taken from a supplied array of ranges.
Inheritance Hierarchy
SystemObject
  Kaos.CombinatoricsProduct

Namespace:  Kaos.Combinatorics
Assembly:  KaosCombinatorics (in KaosCombinatorics.dll) Version: 5.0.0.6
Syntax
C#
public class Product : IComparable, IEnumerable, 
	IComparable<Product>, IEquatable<Product>, IEnumerable<int>

The Product type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCode exampleItem
Get an element of the Product at the supplied column.
Public propertyCode exampleRank
Row index of the join in the lexicographically ordered Product table.
Public propertyRowCount
Count of distinct joins in the Product table.
Public propertyWidth
Number of columns in the Product.
Top
Methods
  NameDescription
Public methodCompareTo(Object)
Compare 2 Products.
Public methodCompareTo(Product)
Compare 2 Products.
Public methodCopyTo
Copy the entire sequence to the supplied destination.
Public methodEquals(Object)
Indicate whether 2 Products have the same value.
(Overrides ObjectEquals(Object).)
Public methodEquals(Product)
Indicate whether 2 Products have the same value.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleGetEnumerator
Enumerate all elements of a Product.
Public methodGetHashCode
Get the hash oode of the Product.
(Overrides ObjectGetHashCode.)
Public methodCode exampleGetRows
Iterate thru all rows of the Product table for for every value of Rank ascending.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberCode examplePermuteT
Apply a Product sequence to select from the supplied lists or arrays.
Public methodSize
Get the size of a column.
Public methodCode exampleToString
Provide readable form of the Product row.
(Overrides ObjectToString.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Indicate whether 2 Products are equal.
Public operatorStatic memberGreaterThan
Indicate whether the left Product is greater than the right Product.
Public operatorStatic memberGreaterThanOrEqual
Indicate whether the left Product is greater than or equal to the right Product.
Public operatorStatic memberInequality
Indicate whether 2 Products are not equal.
Public operatorStatic memberLessThan
Indicate whether the left Product is less than the right Product.
Public operatorStatic memberLessThanOrEqual
Indicate whether the left Product is less than or equal to the right Product.
Top
Remarks

A cartesian product is a set of sets where each subset is constructed by picking one element from each of a given number of sets. This process of joining elements to form new sets is repeated until all possible distinct joins are made.

The Product class uses an array of integers as input where each integer is the size of each of the composing sets. The joined sets are represented as rows in a table where each element is a value in the range of these supplied sizes. Rows are constructed by looping thru the rightmost ranges fastest so that the resulting table is lexicographically ordered.

Use the Width property to get the number of joined elements. Use the RowCount property to get the number of distinct joins in the Product table. Use the indexer to get an element of the row. Use the default enumerator to iterate thru the elements of a Product row. Use the Permute method to rearrange a supplied list based on the values in a row.

Use the Rank property to get or set the row index in the ordered Product table of joins. Use GetRows to iterate thru all possible joins of theProduct ordered by Rank.

The default appearance of a Product row is a list of integers (starting at 0) enclosed in braces. The appearance may be tailored 3 ways:

For more information about cartesian products, see:

https://en.wikipedia.org/wiki/Cartesian_product

Examples

Iterating thru new Product (new int[] { 2, 3, 2 }).GetRows() produces:

{ 0, 0, 0 }
{ 0, 0, 1 }
{ 0, 1, 0 }
{ 0, 1, 1 }
{ 0, 2, 0 }
{ 0, 2, 1 }
{ 1, 0, 0 }
{ 1, 0, 1 }
{ 1, 1, 0 }
{ 1, 1, 1 }
{ 1, 2, 0 }
{ 1, 2, 1 }

See Also