什么是在其他集合(组集合)内生成集合(项目集合)组合而不与当前集合(同一组中的项目)的值相交的好(易于阅读和快速运行)方法?
例如,我有两个简单的类。包含一组项目的组
public class Group
{
public string Name { get; set; }
public ISet<Item> Items { get; set; }
}
public class Item
{
public string Name { get; set; }
}
结果,我有一组组,每个组包含一组配置为:
var groupA = new Group
{
Name = "A",
Items = new HashSet<Item> {
new Item { Name = "A1" },
new Item { Name = "A2" },
new Item { Name = "A3" }
}
};
var groupB = new Group
{
Name = "B",
Items = new HashSet<Item> {
new Item { Name = "B1" },
new Item { Name = "B2" },
}
};
var groupC = new Group
{
Name = "C",
Items = new HashSet<Item> {
new Item { Name = "C1" },
new Item { Name = "C2" },
new Item { Name = "C3" },
new Item { Name = "C4" },
}
};
var groupsSet = new HashSet<Group>();
groupsSet.Add(groupA);
groupsSet.Add(groupB);
groupsSet.Add(groupC);
groupsSet
从(1) 和 (2) 等组合中获得的好方法是什么:
1)
A1, B1, C1
A1, B1, C2
A1, B1, C3
A1, B1, C4
A1, B2, C1
A1, B2, C2
A1, B2, C3
A1, B2, C4
A2, B1, C1
A2, B1, C2
A2, B1, C3
A2, B1, C4
A2, B2, C1
A2, B2, C2
A2, B2, C3
A2, B2, C4
A3, B1, C1
A3, B1, C2
A3, B1, C3
A3, B1, C4
A3, B2, C1
A3, B2, C2
A3, B2, C3
A3, B2, C4
2)
A1
A2
A3
B1
B2
C1
C2
C3
C4
A1, B1
A1, B2
A2, B1
A2, B2
A3, B1
A3, B2
A1, C1
A1, C2
A1, C3
A1, C4
A2, C1
A2, C2
A2, C3
A2, C4
A3, C1
A3, C2
A3, C3
A3, C4
B1, C1
B1, C2
B1, C3
B1, C4
B2, C1
B2, C2
B2, C3
B2, C4
A1, B1, C1
A1, B1, C2
A1, B1, C3
A1, B1, C4
A1, B2, C1
A1, B2, C2
A1, B2, C3
A1, B2, C4
A2, B1, C1
A2, B1, C2
A2, B1, C3
A2, B1, C4
A2, B2, C1
A2, B2, C2
A2, B2, C3
A2, B2, C4
A3, B1, C1
A3, B1, C2
A3, B1, C3
A3, B1, C4
A3, B2, C1
A3, B2, C2
A3, B2, C3
A3, B2, C4
当同一组中的项目不相互交叉时,仅与其他组中的项目相交?
组的数量和组中的项目数量可能不同。
组合内的项目顺序不相关。
谢谢你。