@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); }
@SuppressWarnings("unchecked") @Override public V getLongestPrefixValue(CharSequence key) { int len = key.length() - 1; V ret = null; IARTNode current = root; for (int depth = 0; depth < len; depth++) { int index = key.charAt(depth); V x = (V) current.getValue(index); if (x != null) ret = x; current = ((IARTNodeN) current).findNode(index); if (current == null) return ret; } V x = (V) current.getValue(key.charAt(len)); return x != null ? x : ret; }
@SuppressWarnings("unchecked") public V get(CharSequence key) { int len = key.length() - 1; IARTNode current = root; for (int depth = 0; depth < len; depth++) { current = ((IARTNodeN) current).findNode(key.charAt(depth)); if (current == null) return null; } return (V) current.getValue(key.charAt(len)); }