Code example for SortedSet

Methods: add

0
    if (child.parent != null) {
      throw new IllegalArgumentException(
          "The child is already under another node:" + child.parent);
    } 
    checkChildren(); 
    boolean retval = children.add(child);
    if (retval) child.parent = this;
    return retval;
  } 
 
  /** 
   * Does this node have any children? 
   * @return Boolean indicate whether this node has any children. 
   */ 
  public synchronized boolean hasChildren() { 
    return children != null && !children.isEmpty();
  } 
 
  /** 
   * Get the children of this node.