是否可以使用 MSDN 的 LinkedList 类来创建一个父节点指向多个子节点的列表?
我正在尝试用 C# 制作一棵树。许多帖子建议使用链接列表,例如 MSDN 上的 LinkedList 类这是 .NET 框架的一部分。但似乎每个 MSDN LinkedListNode 只能链接到一个子节点(在这种情况下,列表看起来像一条线,而不是像我正在拍摄的分支树)。我错过了什么吗?还有另一篇关于此的文章,人们建议发布者构建他自己的版本,似乎被称为多链接列表( 如何在链表中创建多个节点,然后迭代这些节点)
是时候摆脱困境了吗?母舰并尝试制作我自己的树?我应该创建一个继承自 LinkedListNode 的新的多链接节点类吗?
I'm trying to make a tree with C#. Many posts advise using a linked list, like the LinkedList class on MSDN that is a part of the .NET framework. But it seems like each MSDN LinkedListNode can only link to one child node (in that case the list would look like a line, not like the branching tree I'm shooting for). Am I missing something? There was another post on this, and people advised the poster to just build his own version of what seems to be called a multilinked list ( How to create multiple nodes in a linked list then iterate through the nodes )
Is it time to cut loose from the mothership and try making my own tree? Should I make a new multi-linked node class that inherits from LinkedListNode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标准类库中没有树。您需要编写自己的实现,或者找到可以使用的其他人的实现。
我认为从
LinkedListNode
继承不会获得任何好处。语义不同。There are no trees in the standard class libraries. You need to write your own, or find someone else's implementation that you can use.
I don't think you'd gain anything by inheriting from
LinkedListNode<T>
. The semantics are different.制作您自己的树 - http ://dvanderboom.wordpress.com/2008/03/15/treet-implementing-a-non-binary-tree-in-c/
Make your own Tree - http://dvanderboom.wordpress.com/2008/03/15/treet-implementing-a-non-binary-tree-in-c/