public boolean isRoot (Object var) { int idx = lookupIndex (var); return (parents.get(idx) == null); }
public boolean isRoot (Object var) { int idx = lookupIndex (var); return (parents.get(idx) == null); }
public boolean isRoot (Object var) { int idx = lookupIndex (var); return (parents.get(idx) == null); }
public boolean isLeaf (Object v) { int idx = lookupIndex (v); return ((List)children.get(idx)).size() == 0; }
public boolean isLeaf (Object v) { int idx = lookupIndex (v); return ((List)children.get(idx)).size() == 0; }
public boolean isLeaf (Object v) { int idx = lookupIndex (v); return ((List)children.get(idx)).size() == 0; }
public void addNode (Object parent, Object child) { int id1; if (root == null) { root = parent; id1 = maybeAddVertex (parent); } else if ((id1 = lookupIndex (parent)) == -1) throw new UnsupportedOperationException ("This tree already has a root."); int id2 = maybeAddVertex (child); Object oldParent = parents.get (id2); if ((oldParent != null) && (oldParent != parent)) throw new UnsupportedOperationException ("Trying to change parent of Object "+child+" from " +oldParent+" to "+parent); parents.set (id2, parent); ArrayList childList = (ArrayList) children.get (id1); childList.add (child); }
public void addNode (Object parent, Object child) { int id1; if (root == null) { root = parent; id1 = maybeAddVertex (parent); } else if ((id1 = lookupIndex (parent)) == -1) throw new UnsupportedOperationException ("This tree already has a root."); int id2 = maybeAddVertex (child); Object oldParent = parents.get (id2); if ((oldParent != null) && (oldParent != parent)) throw new UnsupportedOperationException ("Trying to change parent of Object "+child+" from " +oldParent+" to "+parent); parents.set (id2, parent); ArrayList childList = (ArrayList) children.get (id1); childList.add (child); }
public void addNode (Object parent, Object child) { int id1; if (root == null) { root = parent; id1 = maybeAddVertex (parent); } else if ((id1 = lookupIndex (parent)) == -1) throw new UnsupportedOperationException ("This tree already has a root."); int id2 = maybeAddVertex (child); Object oldParent = parents.get (id2); if ((oldParent != null) && (oldParent != parent)) throw new UnsupportedOperationException ("Trying to change parent of Object "+child+" from " +oldParent+" to "+parent); parents.set (id2, parent); ArrayList childList = (ArrayList) children.get (id1); childList.add (child); }