Package org.geotools.graph.util

Examples of org.geotools.graph.util.IndexedStack


   
    //create a map to maintain iterator state
    HashMap node2related = new HashMap();
   
    //create the stack and place start node on
    IndexedStack stack = new IndexedStack();
    stack.push(from);
   
    int iterations = 0;
O: while(!stack.isEmpty() && (iterations++ < m_maxitr)) {
      //peek the stack
      Node top = (Node)stack.peek();
     
      switch(visitor.visit(top)) {
        case END_PATH_AND_CONTINUE:
          paths.add(new Path(stack));
          stack.pop();
          continue;
       
        case END_PATH_AND_STOP:
          paths.add(new Path(stack));
          break O;
       
        case KILL_PATH:
          stack.pop();
          continue;
         
        case CONTINUE_PATH:
         
       
      }
     
      Iterator related = null;
      if ((related = (Iterator)node2related.get(top)) == null) {
        related = top.getRelated();
        node2related.put(top,related);
      }
     
      while(stack.size() < m_maxplen && related.hasNext()) {
        Node adj = (Node)related.next();
        if (stack.contains(adj)) continue;
       
        //push adjacent onto stack, and reset iterator
        stack.push(adj);
        node2related.put(adj, adj.getRelated());
     
        continue O;
      }
       
      //all adjacent have been processed or are in stack
      stack.pop();
    }  

    return(paths);
  }
View Full Code Here

TOP

Related Classes of org.geotools.graph.util.IndexedStack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.