Exemple #1
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();
  }
Exemple #2
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();
  }
Exemple #3
0
 public Node find(Condition condition) {
   for (Iterator iterator = iterator(); iterator.hasNext(); ) {
     if (condition.check(iterator.next())) {
       return iterator.current();
     }
   }
   return null;
 }
Exemple #4
0
 public void forEach(Closure closure) {
   for (Iterator iterator = iterator(); iterator.hasNext(); ) {
     closure.execute(iterator.next());
   }
 }