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

📄 table.java

📁 本程序代码是人工智能中九宫搜索的解决 采用Java语言
💻 JAVA
字号:
import java.util.Vector;

/*
 * Created on 2005-4-16
 *
 * 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
 */
public class Table extends Vector
{
   int stepnow=0;        //搜索到第几个元素
   int stepend=0;        //总共考察的节点数
   boolean  empty=false;     //是否为空
   public void chushi()
   {
   	super.removeAllElements();
    stepnow=0;        
    stepend=0;        
   }
   public synchronized void addElement(jiedian obj)
   {
   	 super.addElement(obj);
   	 stepend++;
   	 empty=true;
   }
   public synchronized void insertElement(jiedian obj,int index)
   {
   	super.insertElementAt(obj,index);
    stepend++;
  	 empty=true;
   }
   public synchronized void removeElementAt(int index)
   {
   	super.removeElementAt(index);
   	stepend--;
   	if(stepend==0)
   		empty=false;
   }
   public synchronized jiedian ElementAt(int index)
   { 
   	jiedian a=new jiedian();
   	a=((jiedian)(super.elementAt(index))).clon();
           return(a);
   }
   public void smallorderinsert(jiedian a)
   {
   	int i=0;   
   	if(this.isEmpty())
   		this.addElement(a);
   	else
   	{
   	   while(i<this.stepend&&a.keyvalue>this.ElementAt(i).keyvalue)
   		  i++;
   	    this.insertElement(a,i);
   	}
   }
   public void largeorderinsert(jiedian a)
   {
   	int i=0;
   	if(this.isEmpty())
   		this.addElement(a);
   	else
   	{
   	   while(i<this.stepend&&a.keyvalue<this.ElementAt(i).keyvalue)
   		  i++;
   	 this.insertElement(a,i);
   	}
   }
   public synchronized boolean isEmpty()
   {
   	return(super.isEmpty());
   }
   public void setempty()
    {
    	super.removeAllElements();
    }
}
 

⌨️ 快捷键说明

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