Author: xor
Date: 2008-10-29 15:49:31 +0000 (Wed, 29 Oct 2008)
New Revision: 23172
Modified:
trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
Log:
Implement Iterable.
Modified: trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
===================================================================
--- trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
2008-10-29 15:45:12 UTC (rev 23171)
+++ trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
2008-10-29 15:49:31 UTC (rev 23172)
@@ -1,6 +1,8 @@
package freenet.support;
import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
/**
* @author amphibian
@@ -9,7 +11,7 @@
* and provides an update() function to move an item when its
* value has changed. Allows duplicates.
*/
-public class UpdatableSortedLinkedList {
+public class UpdatableSortedLinkedList implements Iterable {
boolean debug = false;
protected boolean killed = false;
private static boolean logMINOR;
@@ -253,4 +255,8 @@
dest.add(item);
}
}
+
+ public synchronized Iterator iterator() {
+ return list.iterator();
+ }
}
Modified:
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
===================================================================
---
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
2008-10-29 15:45:12 UTC (rev 23171)
+++
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
2008-10-29 15:49:31 UTC (rev 23172)
@@ -1,6 +1,7 @@
package freenet.support;
import java.util.HashMap;
+import java.util.Iterator;
/**
* UpdatableSortedLinkedList plus a hashtable. Each item has
@@ -41,9 +42,13 @@
map.remove(((IndexableUpdatableSortedLinkedListItem)item).indexValue());
return super.remove(item);
}
+
+ public synchronized IndexableUpdatableSortedLinkedListItem get(Object
key) {
+ return (IndexableUpdatableSortedLinkedListItem)map.get(key);
+ }
- public synchronized boolean containsKey(Object o) {
- return map.containsKey(o);
+ public synchronized boolean containsKey(Object key) {
+ return map.containsKey(key);
}
/**