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

📄 abstractlist.java

📁 赫夫曼编译码器: 用哈夫曼编码进行通信可以大大提高信道利用率
💻 JAVA
字号:
package structure;import java.util.Iterator;/** * An abstract structure implementing features common to all * list-like structures in this package. * <p>        * Lists are typically used to store data of unknown or varying length. * The structure package provides several extensions of the AbstractList class,  * each of which has its particular strengths and weaknesses. * <p> * Example usage: * * To place a copy of every unique parameter passed to a program into a  * List, we could use the following: * <pre> * public static void main({@link java.lang.String String[]} arguments) * { *     {@link AbstractList} argList = new {@link SinglyLinkedList#SinglyLinkedList() SinglyLinkedList()}; *     for (int i = 0; i < arguments.length; i++){ *	   if (!argList.{@link #contains(Object) contains(arguments[i])}){ *	       argList.{@link #add(Object) add(arguments[i])}; *         } *    } *    System.out.println(argList); * } * </pre> * @version $Id: SinglyLinkedList.java,v 4.1 2000/12/29 02:39:16 bailey Exp bailey $ * @author, 2001 duane a. bailey * @see DoublyLinkedList * @see CircularList * @see SinglyLinkedList */public abstract class AbstractList     extends AbstractStructure implements List{    /**     * Default constructor for AbstractLists     * @post does nothing     */    public AbstractList()    {    }    /**     * Determine if list is empty.     *     * @post returns true iff list has no elements     *      * @return True if list has no elements.     */    public boolean isEmpty()    {	return size() == 0;    }    /**     * Add a value to head of list.     *     * @post value is added to beginning of list     *      * @param value The value to be added to head of list.     */    public void addFirst(Object value)    {	add(0,value);    }    /**     * Add a value to tail of list.     *     * @post value is added to end of list     *      * @param value The value to be added to tail of list.     */    public void addLast(Object value)    {	add(size(),value);    }    /**     * Fetch first element of list.     *     * @pre list is not empty     * @post returns first value in list     *      * @return A reference to first element of list.     */    public Object getFirst()    {	return get(0);    }    /**     * Fetch last element of list.     *     * @pre list is not empty     * @post returns last value in list     *      * @return A reference to last element of list.     */    public Object getLast()    {	return get(size()-1);    }    /**     * Remove a value from first element of list.     *     * @pre list is not empty     * @post removes first value from list     *      * @return value actually removed.     */    public Object removeFirst()    {	return remove(0);    }    /**     * Remove last value from list.     *     * @pre list is not empty     * @post removes last value from list     *      * @return value actually removed.     */    public Object removeLast()    {	return remove(size()-1);    }    /**     * Add an object to tail of list.     *     * @post value is added to tail of list     *      * @param value The value to be added to tail of list.     * @see #addLast     */    public void add(Object value)    {	addLast(value);    }    /**     * Removes value from tail of list.     *     * @pre list has at least one element     * @post removes last value found in list     * @return object removed.     */    public Object remove()    {	return removeLast();    }    /**     * Retrieves value from tail of list.     *     * @pre list has at least one element     * @post returns last value found in list     * @return object found at end of list     */    public Object get()    {	return getLast();    }    /**     * Check to see if a value is in list.     *     * @pre value is not null     * @post returns true iff list contains an object equal to value     *      * @param value value sought.     * @return True if value is within list.     */    public boolean contains(Object value)    {	return -1 != indexOf(value);    }}

⌨️ 快捷键说明

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