Exemplo n.º 1
0
 public Node find(Condition condition) {
   for (Iterator iterator = iterator(); iterator.hasNext(); ) {
     if (condition.check(iterator.next())) {
       return iterator.current();
     }
   }
   return null;
 }
Exemplo n.º 2
0
  private static String format(List list) {
    StringBuilder builder = new StringBuilder();
    builder.append('[');

    Iterator it = list.iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
      builder.append(format(entry.getValue()));
      if (it.hasNext()) {
        builder.append(", ");
      }
    }

    builder.append(']');
    return builder.toString();
  }
Exemplo n.º 3
0
  private static String format(Map map) {
    StringBuilder builder = new StringBuilder();
    builder.append('{');

    Iterator it = map.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
      builder.append(entry.getKey()).append(": ").append(format(entry.getValue()));
      if (it.hasNext()) {
        builder.append(", ");
      }
    }

    builder.append('}');
    return builder.toString();
  }
Exemplo n.º 4
0
 public void forEach(Closure closure) {
   for (Iterator iterator = iterator(); iterator.hasNext(); ) {
     closure.execute(iterator.next());
   }
 }