--- projects/cms/source/util/uk/org/iscream/cms/util/Queue.java 2001/01/18 01:55:36 1.3 +++ projects/cms/source/util/uk/org/iscream/cms/util/Queue.java 2001/01/18 19:13:57 1.4 @@ -13,7 +13,7 @@ import uk.ac.ukc.iscream.util.*; * actually contains some elements. * * @author $Author: tdb $ - * @version $Id: Queue.java,v 1.3 2001/01/18 01:55:36 tdb Exp $ + * @version $Id: Queue.java,v 1.4 2001/01/18 19:13:57 tdb Exp $ */ public class Queue { @@ -22,7 +22,7 @@ public class Queue { /** * The current CVS revision of this class */ - public static final String REVISION = "$Revision: 1.3 $"; + public static final String REVISION = "$Revision: 1.4 $"; //---STATIC METHODS--- @@ -113,6 +113,31 @@ public class Queue { } status += "A total of "+_count+" elements have been added to the queues"; return status; + } + + /** + * Returns the size of a given queue. A consumer can use + * this to see how big their queue is at any given time. + * they should use their queue number as the parameter. + * + * @param queue The queue number to query. + * @return the current size of the queue. + */ + public int queueSize(int queue) throws InvalidQueueException { + if (queue >= _lists.size() || _lists.get(queue) == null) { + throw new InvalidQueueException("Requested queue "+queue+" does not exist"); + } + return ((LinkedList) _lists.get(queue)).size(); + } + + /** + * Returns the total numer of elements to have passed + * through this queue (ie. a counter on the add method). + * + * @return the element-ometer + */ + public int elementCount() { + return _count; } /**