Пример #1
0
 static SortedSet<TypeColorEntry> fromPainter(myjava.gui.syntax.Painter painter) {
   Token.Type[] types = Token.Type.values();
   SortedSet<TypeColorEntry> entries = new TreeSet<>();
   for (Token.Type type : types) {
     entries.add(new TypeColorEntry(type, painter.fromType(type)));
   }
   return entries;
 }
Пример #2
0
 /**
  * Find a new name that isn't among the used names.
  *
  * @param prefix
  * @param usedNames
  * @return
  */
 public static String unusedName(String prefix, Iterator usedNames) {
   SortedSet u = new TreeSet();
   while (usedNames.hasNext()) {
     String curr = (String) usedNames.next();
     if (curr.startsWith(prefix)) {
       String postfix = curr.substring(prefix.length());
       u.add(postfix);
     }
   }
   int count = 0;
   while (u.contains(String.valueOf(count))) {
     count++;
   }
   return prefix + count;
 }