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

📄 alist.java

📁 从给定的字母矩阵中查找给定的字典所包含的字符串
💻 JAVA
字号:
/**
 * This is the list for the program. It is an array-based list.
 * It supports the basic operations of the list.
 * 
 * @author Ting Chen  0122070
 * @version 1.0    2003/5/30
 */
public class AList  
{   
	/** Default array size	*/
	private static final int defaultSize = 1000; 

  /** Maximum size of list */
	private int msize;        
	
  /** Actual number of Objects in list */
	private int numInList;  

	/** Array holding list Objects  */         
	private Object[] listArray;     

  /**
	* The constructor for this class. <p>
	* It initializes the list to the default size.
	* 	
	*/
	AList() 
	{ 
	  setup(defaultSize); 
	} 

	/**
	* The constructor for this class. <p>
	* It initializes the list to the  user-specified size.
	* 	
	* @param sz The user-specified size
	*/
	AList( int sz ) 
	{ 
	  setup(sz); 
	}    

   /** 
	 * Do actual actual initialization work.
	 *
	 * @param sz The user-specified size
	 */
	private void setup( int sz ) 
  {    
	  msize = sz;
	  numInList = 0;

	  // Create listArray
	  listArray = new Object[sz];   
	}

  /** 
	 * Clear the elements in the list.
	 *	
	 */
	public void clear()             
	{ 
		numInList = 0; 
	}          

   /** 
	 * Insert Object at tail of list
	 *
	 * @param it The object to be appended.
	 */
	public void append(Object it) 
	{ 
	  if ( !(numInList < msize))
		throw new IllegalArgumentException("List is full");

     // Increment list size
	  listArray[numInList++] = it;  
	}

	/** 
	 *  Get the object at the specified index.
	 *
	 * @param index The index of the specified object.
	 */    
	public Object get( int index )
	{
		if ( index >= 0 && index <numInList)
		{
			return listArray[index];
		}
		else
		throw new IllegalArgumentException("Index out of bounds");
	}
    
   /** 
	 * Return the number of the elements in the list
	 */
	public int length()             
	{ 
		return numInList; 
	}

   /** 
	 *  Return true if list is empty
	 *	
	 */
	public boolean isEmpty()        
	{ 
	   return numInList == 0;
	}
} 

⌨️ 快捷键说明

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