我需要一个树/有向无环图实现,如下所示:
public class TreeNode<K, V> {
private K key; // 'key' for this node, always present
private V value; // 'value' for this node, doesn't have to be set
private TreeNode<K, V> parent;
private Set<TreeNode<K, V>> children;
}
Run Code Online (Sandbox Code Playgroud)
TreeNode仅仅是围绕重点和可能的值的包装(节点不必有设定值).标准API或Commons等中有什么东西可以帮我吗?
我不介意自己写(我当然不是要求大家)我只是不想重新发明轮子.