⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 表.java

📁 图搜索策略九宫重排演示程序
💻 JAVA
字号:
/*
 * Created on 2005-4-11
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author 陈凯
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

import java.util.*;

public class 表 extends Vector
{
	表()	//构造函数
	{
		super();
	}
	
	public void 初始化()
	{		
		this.removeAllElements();
	}
	
	//取得OPEN表中结点的个数
	public int 取结点个数()
	{
		return this.size();
	}
	
	//在OPEN表的尾部加入一个结点
	public void 加入结点(Object obj)
	{
		this.addElement(obj);		
	}
	
//	在OPEN表的首部加入一个结点
	public void 加入结点到表首(Object obj)
	{
		this.insertElementAt(obj,0);
	}
	
	//从OPEN表的头部取出一个结点
	public Object 取出结点()
	{
		Object obj=this.elementAt(0);
		this.removeElementAt(0);		
		return obj;
	}
	
	//判断表是否为空
	public boolean 是否为空()
	{
		if(this.size()==0)
			return true;
		else return false;
	}
	
	public boolean 结点是否在表中(Object node)
	{
		boolean retv=false;
		Object  pnode;
		
		for(int i=0;i<this.取结点个数();i++)
		{
			pnode=this.elementAt(i);
			if(pnode.equals(node)==true)
			{
				retv=true;
				break;
			}
		}
		
		return retv;
	}
	
	public void 计算结点代价估计值()
	{
		for(int i=0;i<this.size();i++)
		{
			((九宫图结点)this.elementAt(i)).计算代价估计值();
		}
	}
	
	public void 排序加入结点(九宫图结点 node)
	{
		for(int i=0;i<this.size();i++)
		{
			if(node.取代价估计值()<((九宫图结点)this.elementAt(i)).取代价估计值())
			{
				this.insertElementAt(node,i);				
				return;
			}
		}
		this.addElement(node);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -