예제 #1
0
 /**
  * Choose a unique tab file.
  *
  * @return io reference
  */
 private IOFile newTabFile() {
   // collect numbers of existing files
   final BoolList bl = new BoolList();
   for (final EditorArea edit : editors()) {
     if (edit.opened()) continue;
     final String n = edit.file.name().substring(FILE.length());
     bl.set(n.isEmpty() ? 1 : Integer.parseInt(n), true);
   }
   // find first free file number
   int c = 0;
   while (++c < bl.size() && bl.get(c)) ;
   // create io reference
   return new IOFile(gui.gprop.get(GUIProp.WORKPATH), FILE + (c == 1 ? "" : c));
 }
예제 #2
0
  /**
   * Adds values to the index.
   *
   * @param key key to be indexed
   * @param vals sorted values
   */
  void add(final byte[] key, final int... vals) {
    // token index: add values. otherwise, reference existing values
    final int id = type == IndexType.TOKEN ? values.put(key) : values.id(key), vl = vals.length;
    // updatable index: if required, resize existing arrays
    while (idsList.size() < id + 1) idsList.add(null);
    if (lenList.size() < id + 1) lenList.set(id, 0);

    final int len = lenList.get(id), size = len + vl;
    int[] ids = idsList.get(id);
    if (ids == null) {
      ids = vals;
    } else {
      if (ids.length < size) ids = Arrays.copyOf(ids, Array.newSize(size));
      System.arraycopy(vals, 0, ids, len, vl);
      if (ids[len - 1] > vals[0]) {
        if (reorder == null) reorder = new BoolList(values.size());
        reorder.set(id, true);
      }
    }
    idsList.set(id, ids);
    lenList.set(id, size);
  }