对应于子树的节点是否有特定的名称? [英] Is there a specific name for the node that coresponds to a subtree?

查看:160
本文介绍了对应于子树的节点是否有特定的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个网站导航层次结构。它是一个节点树。节点表示网页。



树上的某些节点是特殊的。我需要一个名字。



有多个这样的节点。每个都是具有不同标志,样式表或布局的页面的子树的根。想想不同的部门。



使用带颜色编码的子树的网站地图http://img518.imageshack.us/img518/153/subtreesfe1.gif



我该命名什么节点类型

解决方案

Root(具有子节点但没有父节点的节点),Node(带有子节点和父节点的节点)和Leaf(没有孩子和父母的节点)?



然后,如果需要,您可以根据树结构中的名称和位置来区分(例如DepartmentRoot,DepartmentNode,DepartmentLeaf)。



从OP

更新以下评论

看着你的问题,你说一些是特别的,在您的图表中,您有不同的节点在不同的级别看起来不同。节点的设计可能不同,您可以多种方式构建树结构。例如,一个单一的抽象类可以具有子节点,如果没有子节点,它的叶子,如果没有父,它的根,但这可以改变其生命周期。或者,一个固定的类结构,其中叶是特定的类类型,不能将孩子以任何方式添加到他们中。



如果您的设计不需要你根据它们的位置(相对于根)来区分节点,它表明你有一个用于它们的抽象类。



在这种情况下,它提出了一个问题,如何不同?



如果它与其他地方的标准节点完全相同,但有一点样式,StyledNode 如何?你甚至需要它是分开的(没有风格==没有什么大不了,它不渲染)。



由于我不知道如何树是架构的,命名时可能会考虑几个因素。


I'm designing a web site navigation hierarchy. It's a tree of nodes. Nodes represent web pages.

Some nodes on the tree are special. I need a name for them.

There are multiple such nodes. Each is the "root" of a sub-tree with pages that have a distinct logo, style sheet, or layout. Think of different departments.

site map with color-coded sub-trees http://img518.imageshack.us/img518/153/subtreesfe1.gif

What should I name this type of node?

解决方案

How about Root (node with children, but no parent), Node (node with children and parent) and Leaf (node with no children and parent)?

You can then distinguish by name and position within the tree structure (E.g. DepartmentRoot, DepartmentNode, DepartmentLeaf) if need be..

Update Following Comment from OP

Looking at your question, you said that "some" are special, and in your diagram, you have different nodes looking differently at different levels. The nodes may be different in their design, you can build a tree structure many ways. For example, a single abstract class that can have child nodes, if no children, its a leaf, if no parent, its a root but this can change in its lifetime. Or, a fixed class structure in which leafs are a specific class type that cannot have children added to them in any way.

IF your design does not need you to distinguish nodes differently depending on their position (relative to the root) it suggests that you have an abstract class used for them all.

In which case, it raises the question, how is it different?

If it is simply the same as the standard node everywhere else, but with a bit of styling, how about StyledNode? Do you even need it to be seperate (no style == no big deal, it doesn't render).

Since I don't know the mechanics of how the tree is architected, there could possibly be several factors to consider when naming.

这篇关于对应于子树的节点是否有特定的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆