/** * @return the number of ancestors of the node at the specified index. * Root nodes have depth 0, other nodes depth is one * greater than the depth of their parent node. */ public int depth(int visibleIndex) { return getTreeNode(visibleIndex).path.size() - 1; }
/** * @return the number of ancestors of the node at the specified index. * Root nodes have depth 0, other nodes depth is one * greater than the depth of their parent node. */ public int depth(int visibleIndex) { return getTreeNode(visibleIndex).path.size() - 1; }
/** * @return the number of ancestors of the node at the specified index. * Root nodes have depth 0, other nodes depth is one * greater than the depth of their parent node. */ public int depth(int visibleIndex) { return getTreeNode(visibleIndex).path.size() - 1; }
/** {@inheritDoc} */ @Override public E get(int visibleIndex) { return getTreeNode(visibleIndex).getElement(); }
/** {@inheritDoc} */ @Override public E get(int visibleIndex) { return getTreeNode(visibleIndex).getElement(); }
/** {@inheritDoc} */ @Override public E get(int visibleIndex) { return getTreeNode(visibleIndex).getElement(); }
/** * Get a {@link List} containing all {@link Node}s with no parents in the * tree. */ public List<Node<E>> getRoots() { // todo: make this fast List<Node<E>> result = new ArrayList<Node<E>>(); for(int i = 0; i < size(); i++) { Node<E> possibleRoot = getTreeNode(i); if(possibleRoot.pathLength() == 1) { result.add(possibleRoot); } } return result; }
/** * Get a {@link List} containing all {@link Node}s with no parents in the * tree. */ public List<Node<E>> getRoots() { // todo: make this fast List<Node<E>> result = new ArrayList<Node<E>>(); for(int i = 0; i < size(); i++) { Node<E> possibleRoot = getTreeNode(i); if(possibleRoot.pathLength() == 1) { result.add(possibleRoot); } } return result; }
/** * Get a {@link List} containing all {@link Node}s with no parents in the * tree. */ public List<Node<E>> getRoots() { // todo: make this fast List<Node<E>> result = new ArrayList<Node<E>>(); for(int i = 0; i < size(); i++) { Node<E> possibleRoot = getTreeNode(i); if(possibleRoot.pathLength() == 1) { result.add(possibleRoot); } } return result; }
/** * @return <code>true</code> if the node at the specified index has * children, regardless of whether such children are visible. */ public boolean hasChildren(int visibleIndex) { boolean hasChildren = subtreeSize(visibleIndex, true) > 1; boolean isLeaf = getTreeNode(visibleIndex).isLeaf(); if(isLeaf == hasChildren) { subtreeSize(visibleIndex, true, true); } return hasChildren; }
/** * @return <code>true</code> if the node at the specified index has * children, regardless of whether such children are visible. */ public boolean hasChildren(int visibleIndex) { boolean hasChildren = subtreeSize(visibleIndex, true) > 1; boolean isLeaf = getTreeNode(visibleIndex).isLeaf(); if(isLeaf == hasChildren) { subtreeSize(visibleIndex, true, true); } return hasChildren; }
/** * @return <code>true</code> if the node at the specified index has * children, regardless of whether such children are visible. */ public boolean hasChildren(int visibleIndex) { boolean hasChildren = subtreeSize(visibleIndex, true) > 1; boolean isLeaf = getTreeNode(visibleIndex).isLeaf(); if(isLeaf == hasChildren) { subtreeSize(visibleIndex, true, true); } return hasChildren; }