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

📄 queue.java

📁 专业汽车级嵌入式操作系统OSEK的源代码
💻 JAVA
字号:
package java.util;/** $Log: Queue.java,v $* Revision 1.2  2005/11/23 17:46:45  mpscholz* minor javadoc related changes** Revision 1.1  2003/08/17 14:59:42  mpscholz* enhanced Vector* added Stack and Queue and associated exception classes**///////////////////////////////////////////////////////////** * A FIFO Queue of objects.  */public class Queue extends Vector {	////////////////////////////////////////////	// constants	////////////////////////////////////////////    	////////////////////////////////////////////	// fields	////////////////////////////////////////////	////////////////////////////////////////////	// constructors	////////////////////////////////////////////	////////////////////////////////////////////    /**     * creates a new Queue instance     */    public Queue() {    	// do nothing    } // Queue()	////////////////////////////////////////////	/**	 * pushes an object onto the Queue	 * @param anObject the object	 * @return Object the object pushed onto the Queue	 */    public Object push(Object anObject) {    	// add the object to base vector		addElement(anObject);		return anObject;    } // push()	////////////////////////////////////////////	/**	 * fetches an object from the start of the Queue	 * and removes it	 * @return Object the object removed from the start of the stock	 * @throws EmptyQueueException	 */    public synchronized Object pop() throws EmptyQueueException {		// get object		Object popped = peek();		// remove and return object		removeElementAt(0);		return popped;    } // pop()	////////////////////////////////////////////	/**	 * fetches an object from the start of the Queue	 * <br>does not remove it!	 * @return Object the object at the start of the Queue	 * @throws EmptyQueueException	 */    public synchronized Object peek() throws EmptyQueueException {		// empty Queue?		if(size()==0)	    	throw new EmptyQueueException();	    // return first element		return elementAt(0);    } // peek()	////////////////////////////////////////////	/**	 * is this Queue empty?	 * @return boolean true, if the Queue is empty	 */    public boolean empty() {		return (size()==0);    } // empty()} // class Queue

⌨️ 快捷键说明

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