예제 #1
0
파일: NSNode.java 프로젝트: phspaelti/basex
  /**
   * Recursively deletes the specified namespace URI reference.
   *
   * @param uri namespace URI reference
   */
  void delete(final int uri) {
    for (int c = 0; c < sz; ++c) children[c].delete(uri);

    final int vl = values.length;
    for (int v = 0; v < vl; v += 2) {
      if (values[v + 1] != uri) continue;
      final int[] vals = new int[vl - 2];
      System.arraycopy(values, 0, vals, 0, v);
      System.arraycopy(values, v + 2, vals, v, vl - v - 2);
      values = vals;
      break;
    }
  }
예제 #2
0
파일: TextView.java 프로젝트: dirkk/basex
 /**
  * Sets the output text.
  *
  * @param out cached output
  */
 public void setText(final ArrayOutput out) {
   final byte[] buf = out.buffer();
   final int size = (int) out.size();
   final byte[] chop = token(DOTS);
   if (out.finished() && size >= chop.length) {
     System.arraycopy(chop, 0, buf, size - chop.length, chop.length);
   }
   text.setText(buf, size);
   header.setText((out.finished() ? CHOPPED : "") + RESULT);
   home.setEnabled(gui.context.data() != null);
 }
예제 #3
0
파일: NSNode.java 프로젝트: phspaelti/basex
  /**
   * Adds the specified node into the child array, which is sorted by pre values.
   *
   * @param node child node
   */
  void add(final NSNode node) {
    if (sz == children.length) children = Array.copy(children, new NSNode[Array.newSize(sz)]);

    // find inserting position
    int s = find(node.pr);
    if (s < 0 || node.pr != children[s].pr) s++;

    System.arraycopy(children, s, children, s + 1, sz++ - s);
    children[s] = node;
    node.parent = this;
  }
예제 #4
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);
  }
예제 #5
0
파일: NSNode.java 프로젝트: phspaelti/basex
  /**
   * Deletes nodes in the specified range (p .. p + sz - 1) and updates the following pre values
   *
   * @param pre pre value
   * @param size number of nodes to be deleted, or actually the size of the pre value which is to be
   *     deleted
   */
  void delete(final int pre, final int size) {
    // find the pre value which must be deleted
    int s = find(pre);
    /* if the node is not directly contained as a child, either start at array
     * index 0 or proceed with the next node in the child array to search for
     * descendants of pre
     */
    if (s == -1 || children[s].pr != pre) ++s;
    // first pre value which is not deleted
    final int upper = pre + size;
    // number of nodes to be deleted
    int num = 0;
    // determine number of nodes to be deleted
    for (int i = s; i < sz && children[i].pr < upper; ++i, ++num) ;
    // new size of child array
    sz -= num;

    // if all nodes are deleted, just create an empty array
    if (sz == 0) children = new NSNode[0];

    // otherwise remove nodes from the child array
    else if (num > 0) System.arraycopy(children, s + num, children, s, sz - s);
  }