001 /* 002 * Generic Queue Interface 003 * $Id: Queue.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $ 004 * 005 * Developed for "Rethinking CS101", a project of Lynn Andrea Stein's AP Group. 006 * For more information, see <a href="http://www.ai.mit.edu/projects/cs101/">the 007 * CS101 homepage</a> or email <las@ai.mit.edu>. 008 * 009 * Copyright (C) 1998 Massachusetts Institute of Technology. 010 * Please do not redistribute without obtaining permission. 011 */ 012 013 package cs101.util.queue; 014 015 import java.util.Enumeration; 016 017 /** 018 * Generic Queue Interface. Allows insertion/deletion at either end. 019 * <p> 020 * Copyright (c) 1998 Massachusetts Institute of Technology 021 * 022 * @author Todd C. Parnell, tparnell@ai.mit.edu 023 * @version $Id: Queue.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $ 024 */ 025 public interface Queue { 026 027 public static final int FRONT = 0; 028 public static final int BACK = 1; 029 030 /** Returns the number of elements in this. */ 031 public int size(); 032 033 /** 034 * Gets the tail object from the queue </B>without</B> removing 035 * it. 036 */ 037 public Object peek(); 038 039 /** 040 * Gets the object from the specified end of the queue 041 * </B>without</B> removing it. 042 */ 043 public Object peek(int end); 044 045 /** Puts obj into the front the queue. */ 046 public void enqueue(Object obj); 047 048 /** Puts obj into the specified end of the queue. */ 049 public void enqueue(Object obj, int end); 050 051 /** Removes and returns the Object at the tail of the queue. */ 052 public Object dequeue(); 053 054 /** Removes and returns the Object at the specified end of the queue. */ 055 public Object dequeue(int end); 056 057 /** Tests whether the queue is empty. */ 058 public boolean isEmpty (); 059 060 /** Returns an Enumeration of the Objects in the queue.<p> 061 * 062 * <I>Note: Do not modify the queue while enumerating--unpredictable 063 * behavior may result.</I> 064 * 065 * @see java.util.Enumeration 066 */ 067 public Enumeration elements(); 068 069 } 070 071 /* 072 * $Log: Queue.java,v $ 073 * Revision 1.1.1.1 2002/06/05 21:56:32 root 074 * CS101 comes to Olin finally. 075 * 076 * Revision 1.1 2000/04/24 22:17:18 nathanw 077 * Bulk reorganization 078 * 079 * Revision 1.12 1999/07/27 16:59:16 las 080 * Updated cs101.util.Queue.java to spell its method peek() 081 * 082 * Revision 1.11 1999/01/21 20:49:19 tparnell 083 * Made Queue.java an interface and added DefaultQueue.java as an implementation. 084 * 085 * Revision 1.10 1998/07/31 21:42:36 tparnell 086 * bugfix 087 * 088 * Revision 1.9 1998/07/31 21:39:01 tparnell 089 * added size() method 090 * 091 * Revision 1.8 1998/07/24 17:19:33 tparnell 092 * Placate new javadoc behavior 093 * 094 */