Ejemplo n.º 1
0
 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;
     }
   }
 }
Ejemplo n.º 2
0
 @Override
 public void add(String fqn, T userData) {
   FqnCacheNode<T> n = _root;
   for (String part : getParts(fqn)) {
     n = n.getOrCreateChild(part);
   }
   n.setUserData(userData);
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 @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;
 }
Ejemplo n.º 5
0
 @Override
 public Set<String> getFqns() {
   Set<String> names = new HashSet<String>();
   _root.collectNames(names, "");
   return names;
 }
Ejemplo n.º 6
0
 @Override
 public final void clear() {
   _root.clear();
 }
Ejemplo n.º 7
0
 @Override
 public final T get(String fqn) {
   FqnCacheNode<T> n = getNode(fqn);
   return n == null ? null : n.getUserData();
 }
Ejemplo n.º 8
0
 public void visitBreadthFirst(Predicate<T> visitor) {
   List<FqnCacheNode<T>> copy = new ArrayList<FqnCacheNode<T>>(_root.getChildren());
   for (FqnCacheNode<T> child : copy) {
     child.visitBreadthFirst(visitor);
   }
 }