排列数据结构
我需要一些有关排列的帮助。
我的问题是这样的:在我们的系统中,我们有各种设备运行各种软件组件。我有兴趣找到所述组件版本的所有排列(唯一组合),并最终得到元组或结构的列表,
struct Permutation
{
IComparable Software1{ get; set; }
IComparable Software2{ get; set; }
IComparable Software3{ get; set; }
}
然后得到这样的列表:
Software1: v1
Software2: v1
Software3: v1
Software1: v1
Software2: v2
Software3: v1
Software1: v2
Software2: v1
Software3: v1
该软件存在于以树结构组织的各种组件上(节点->项目)。子节点的类型告诉我要查找哪种软件
Node->Root (L0)
Node->Parent (L1)
Node->ChildType1 (L2): has property Software1, Software2
Node->ChildType2 (L2): has property Software3
我可以使用 node.Children
(IList
) 和 node 轻松导航树.Parent
(节点
)。
我想按顺序迭代树并构建所有排列的列表。 .net 框架中是否有一个好的现有数据结构可供我使用,或者有人对如何解决它有任何建议吗?
I'm in need of some assistance regarding permutations.
My problem is this: In our system we have various devices running various software components. Im interested in finding all the permutations (unique combinations) of the versions of said components, and end up with a list of tuples or structs ala this
struct Permutation
{
IComparable Software1{ get; set; }
IComparable Software2{ get; set; }
IComparable Software3{ get; set; }
}
Then end up with a list like this:
Software1: v1
Software2: v1
Software3: v1
Software1: v1
Software2: v2
Software3: v1
Software1: v2
Software2: v1
Software3: v1
The software exists on various components organized in a tree structure (Node->Item). The type of the child node tells me which kind of software to look up
Node->Root (L0)
Node->Parent (L1)
Node->ChildType1 (L2): has property Software1, Software2
Node->ChildType2 (L2): has property Software3
I can easily navigate the tree with node.Children
(IList<Node>
) and node.Parent
(Node
).
I want to inorder-iterate the tree and build a list of all permutations. Is there a good existing data structure in the .net framework which I can use for this, or does anyone have any suggestions on how to solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的想法是这样的:
您需要确保排列具有可比性和等同性:
我使用 resharper 来进行跑腿工作:)
My thoughts would be along these lines:
You'll want to make sure that Permutation is comparable and equatable just fine:
I used resharper to do the legwork there :)