Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我想在 Node() 中存储其他信息,例如:左子树中的节点数和右子树中的节点数。我调用的每个插入/添加最终都应该在途中更新这些计数器。问题是 JAVA API 不提供这个句柄,只更新这个节点。
有没有办法我可以获得句柄或提供一些函数,JAVA 可以在每次找到节点时调用它,并且在该函数中我可以更新这些计数器。
对于任何给定的 TreePath 节点,我们可以使用 TreeMap.head 或 TreeMap.tail 来获取树的左侧或右侧,然后在返回的结构上调用 size() 来检查它的大小。