incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r734872 - in /incubator/droids/trunk/droids-core/src/main/java/org/apache/droids: api/TaskQueue.java impl/SimpleTaskQueue.java
Date Fri, 16 Jan 2009 00:33:42 GMT
Author: ryan
Date: Thu Jan 15 16:33:42 2009
New Revision: 734872

URL: http://svn.apache.org/viewvc?rev=734872&view=rev
Log:
DROIDS-39 TaskQueue.peek()

Modified:
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/TaskQueue.java
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueue.java

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/TaskQueue.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/TaskQueue.java?rev=734872&r1=734871&r2=734872&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/TaskQueue.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/TaskQueue.java
Thu Jan 15 16:33:42 2009
@@ -79,4 +79,9 @@
    * @return number of tasks do we have <em>left</em> in the queue.
    */
   int getSize();
+  
+  /**
+   * Get the top 'size' elements in the queue 
+   */
+  Collection<? extends T> peek( int size );
 }
\ No newline at end of file

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueue.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueue.java?rev=734872&r1=734871&r2=734872&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueue.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueue.java
Thu Jan 15 16:33:42 2009
@@ -16,7 +16,9 @@
  */
 package org.apache.droids.impl;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentHashMap;
@@ -128,4 +130,14 @@
   public void setMaxSize(int maxSize) {
     this.maxSize = maxSize;
   }
+
+  @Override
+  public Collection<? extends T> peek(int size) {
+    ArrayList<T> vals = new ArrayList<T>( size );
+    Iterator<T> iter = queue.iterator();
+    while( iter.hasNext() && vals.size() < size ) {
+      vals.add( iter.next() );
+    }
+    return vals;
+  }
 }



Mime
View raw message