/** * Provides a collection of all the nodes in the tree * using a breadth-first traversal. * * @param preorder if false, a postorder breadth-first traversal will be performed * @return the list of (breadth-first) ordered nodes * @since 2.5.0 */ public List breadthFirst(boolean preorder) { List answer = new NodeList(); if (preorder) answer.add(this); answer.addAll(breadthFirstRest(preorder)); if (!preorder) answer.add(this); return answer; }
/** * Calls the provided closure for all the nodes in the tree * using a breadth-first traversal. * A boolean 'preorder' options is supported. * * @param options map containing options * @param c the closure to run for each node (a one or two parameter can be used; if one parameter is given the * closure will be passed the node, for a two param closure the second parameter will be the level). * @since 2.5.0 */ public void breadthFirst(Map<String, Object> options, Closure c) { boolean preorder = Boolean.valueOf(options.get("preorder").toString()); if (preorder) callClosureForNode(c, this, 1); breadthFirstRest(preorder, 2, c); if (!preorder) callClosureForNode(c, this, 1); }
/** * Provides a collection of all the nodes in the tree * using a breadth-first traversal. * * @return the list of (breadth-first) ordered nodes */ public List breadthFirst() { List answer = new NodeList(); answer.add(this); answer.addAll(breadthFirstRest()); return answer; }
/** * Provide a collection of all the nodes in the tree * using a breadth-first traversal. * * @return the list of (breadth-first) ordered nodes */ public List breadthFirst() { List answer = new NodeList(); answer.add(this); answer.addAll(breadthFirstRest()); return answer; }
/** * Provide a collection of all the nodes in the tree * using a breadth-first traversal. * * @return the list of (breadth-first) ordered nodes */ public List breadthFirst() { List answer = new NodeList(); answer.add(this); answer.addAll(breadthFirstRest()); return answer; }
/** * Provide a collection of all the nodes in the tree * using a breadth-first traversal. * * @return the list of (breadth-first) ordered nodes */ public List breadthFirst() { List answer = new NodeList(); answer.add(this); answer.addAll(breadthFirstRest()); return answer; }