更新时间:2023-12-01 16:58:04
对于树结构而言,这似乎非常简单.节点中的accept
方法如下所示:
It seems pretty straightforward for a tree structure. The accept
method in a node could look like this:
void accept(Visitor visitor) {
visitor.visitMyTypeOfNode(this);
for each child {
child.accept(visitor);
}
}
显然,您需要考虑这对于您的应用程序的整体体系结构是否有意义.
Obviously you need to consider if this makes sense in the overall architecture of your application.