我想定义一个这样的时间界面:
public interface TimeInterface<T>
{
static T ZERO;
static T INFINITY;
// some other methods...
}
Run Code Online (Sandbox Code Playgroud)
这可能,或如何做到这一点,以避免错误?
提前致谢!
假设我在树中有一个节点,我怎样才能获得其祖先是这个节点的所有叶子节点?我已经像这样定义了TreeNode:
public class TreeNode<T>
{
/** all children of the node */
private List<TreeNode<T>> children = new ArrayList<TreeNode<T>>();
/** the parent of the node, if the node is root, parent = null */
private TreeNode<T> parent = null;
/** the stored data of the node */
private T data = null;
/** the method I want to implement */
public Set<TreeNode<T>> getAllLeafNodes()
{
Set<TreeNode<T>> leafNodes = new HashSet<TreeNode<T>>();
return leafNodes;
}
}
Run Code Online (Sandbox Code Playgroud)