| ProductPermuteT Method |
Apply a
Product sequence to select from the supplied lists or arrays.
Namespace:
Kaos.Combinatorics
Assembly:
KaosCombinatorics (in KaosCombinatorics.dll) Version: 5.0.0.6
Syntax public static List<T> Permute<T>(
Product arrangement,
IList<IList<T>> source
)
Parameters
- arrangement
- Type: Kaos.CombinatoricsProduct
New arrangement for items. - source
- Type: System.Collections.GenericIListIListT
List of List of Items or arrays to rarrange.
Type Parameters
- T
- Type of items to rearrange.
Return Value
Type:
ListTList of rearranged items.
Exceptions Examples using System;
using System.Collections.Generic;
using Kaos.Combinatorics;
namespace ExampleApp
{
public class Furniture
{
public string Name { get; private set; }
public Furniture (string name) { Name = name; }
public override string ToString() => Name;
}
public class Fruit
{
public string Name { get; private set; }
public Fruit (string name) { Name = name; }
public override string ToString() => Name;
}
class PtExample03
{
static void Main()
{
var colors = new List<object> { "aqua", "black", "crimson" };
var things = new List<object>
{
new Fruit ("apple"),
new Furniture ("bench"),
new Furniture ("chair"),
new Fruit ("durian"),
new Fruit ("eggplant")
};
var lists = new List<object>[] { colors, things };
int[] counts = { colors.Count, things.Count };
foreach (var row in new Product (counts).GetRows())
Console.WriteLine (String.Join (" ", Product.Permute (row, lists)));
}
}
}
See Also