Beispiel #1
0
  @SuppressWarnings("unchecked")
  @Override
  public Iterator<V> allPrefixesOf(CharSequence key) {

    int len = key.length() - 1;
    if (len < 0) return AOpenIterator.<V>empty();

    Object[] ary = new Object[len + 1];
    int maxNode = -1;
    IARTNode current = root;
    for (int depth = 0; depth < len; depth++) {
      int index = key.charAt(depth);
      V x = (V) current.getValue(index);
      if (x != null) {
        maxNode = depth;
        ary[depth] = x;
      }

      current = ((IARTNodeN) current).findNode(index);
      if (current == null) return new ValueArrayIterator<V>(ary, maxNode);
    }

    V x = (V) current.getValue(key.charAt(len));
    if (x != null) {
      ary[len] = x;
      maxNode = len;
    }
    return new ValueArrayIterator<V>(ary, maxNode);
  }
 /*
  * (non-Javadoc)
  *
  * @see org.openl.types.ITypeLibrary#types()
  */
 @Override
 public Iterator<String> typeNames() {
   return AOpenIterator.select(super.typeNames(), selector);
 }