看到很多树形结构的类都是这样的(引用子节点):
class Tree {
String name;
List<Tree> childList;
}
为啥不是(引用父节点)
class Tree {
String name;
List<Tree> parentList;
}
或(同时引用父节点和子节点)
class Tree {
String name;
List<Tree> childList;
List<Tree> parentList;
}
呢