public void visitDepthFirst(Predicate<T> visitor) { List<FqnCacheNode<T>> copy = new ArrayList<FqnCacheNode<T>>(_root.getChildren()); for (FqnCacheNode<T> child : copy) { if (!child.visitDepthFirst(visitor)) { return; } } }
@Override public void add(String fqn, T userData) { FqnCacheNode<T> n = _root; for (String part : getParts(fqn)) { n = n.getOrCreateChild(part); } n.setUserData(userData); }
public FqnCacheNode<T> getNode(String fqn) { FqnCacheNode<T> n = _root; for (String part : getParts(fqn)) { n = n.getChild(part); if (n == null) { break; } } return n; }
@Override public boolean remove(String fqn) { FqnCacheNode<T> n = _root; for (String part : getParts(fqn)) { n = n.getChild(part); if (n == null) { return false; } } n.delete(); return true; }
@Override public Set<String> getFqns() { Set<String> names = new HashSet<String>(); _root.collectNames(names, ""); return names; }
@Override public final void clear() { _root.clear(); }
@Override public final T get(String fqn) { FqnCacheNode<T> n = getNode(fqn); return n == null ? null : n.getUserData(); }
public void visitBreadthFirst(Predicate<T> visitor) { List<FqnCacheNode<T>> copy = new ArrayList<FqnCacheNode<T>>(_root.getChildren()); for (FqnCacheNode<T> child : copy) { child.visitBreadthFirst(visitor); } }