栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Java 链表节点值

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java 链表节点值

public class AStar
{
  private List openList;
  private List closeList;
  private int startX,startY,endX,endY;

  public AStar(){
    openList=new ArrayList();
    closeList=new ArrayList();
   }

    public static void main(String[] args) {
       int[][] map = new int[][] {
              {1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
              {1, 1, 1, 1, 0, 1, 1, 1, 1, 1 },
              {1, 1, 1, 1, 0, 1, 1, 1, 1, 1 },
              {1, 1, 1, 1, 0, 1, 1, 1, 1, 1 },
              {1, 1, 1, 1, 0, 1, 1, 1, 1, 1 },
              {1, 1, 1, 1, 0, 1, 1, 1, 1, 1 }
              };
       Astar astar=new Astar();
       astar.search(0,0, 5, 9);
    }


  public int search(int startX,int startY,int endX,int endY){
   if((index=contain(openList,end.x,end.y))!=-1){//如果不等于-1就到终点
      int count=-1;
      Node nowNode=openList.get(index);
      Node getNode=nowNode;//不太明白之处
      while(getNode.father!=null)
       {
         getNode=getNode.father;
         count++;
       }
    }


private int contain(List nodes,int x,int y){
   Node node=null;
   for(int i=0;i      {
       node=nodes.get(i);
       if(node.x==x&&node.y==y)
           return i;
      }
      return -1;

 }


public Node(int x,int y,Node father){
    this.x=x;
    this.y=y;
    this.father=father;
  }

}
 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/329015.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号