Author: j16sdiz
Date: 2009-04-07 04:45:49 +0000 (Tue, 07 Apr 2009)
New Revision: 26588
Modified:
trunk/freenet/src/freenet/support/TimeSortedHashtable.java
Log:
Fix pairsAfter() with timestamp
Modified: trunk/freenet/src/freenet/support/TimeSortedHashtable.java
===================================================================
--- trunk/freenet/src/freenet/support/TimeSortedHashtable.java 2009-04-07 04:45:29 UTC (rev 26587)
+++ trunk/freenet/src/freenet/support/TimeSortedHashtable.java 2009-04-07 04:45:49 UTC (rev 26588)
@@ -1,5 +1,6 @@
package freenet.support;
+import java.lang.reflect.Array;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -166,9 +167,10 @@
/**
* @return The set of values after the given time.
*/
- // FIXME this is broken if timestamp != -1
public final synchronized <E extends Comparable> E[] valuesAfter(long t, E[] values) {
Set<Comparable> s = elements.tailSet(t, false);
+ if (values.length != s.size())
+ values = (E[]) Array.newInstance(values.getClass().getComponentType(), s.size());
int x = 0;
for(Iterator<Comparable> i = s.iterator();i.hasNext();) {
@@ -200,7 +202,6 @@
assert(elements.size() == valueToElement.size());
}
- // FIXME this is broken if timestamp != -1
public final synchronized <E extends Comparable> Object[] pairsAfter(long timestamp, E[] valuesArray) {
return new Object[] { valuesAfter(timestamp, valuesArray), timesAfter(timestamp) };
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.