diff --git a/src/main/java/com/threerings/presents/dobj/OidList.java b/src/main/java/com/threerings/presents/dobj/OidList.java
index c74b09c6e..e59fcbf07 100644
--- a/src/main/java/com/threerings/presents/dobj/OidList.java
+++ b/src/main/java/com/threerings/presents/dobj/OidList.java
@@ -21,6 +21,9 @@
package com.threerings.presents.dobj;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
import com.threerings.io.Streamable;
/**
@@ -35,7 +38,8 @@ import com.threerings.io.Streamable;
*
When an object is destroyed, its oid is automagically removed from any OidLists.
*
*/
-public class OidList implements Streamable
+public class OidList
+ implements Streamable, Iterable
{
/**
* Creates an empty oid list.
@@ -148,6 +152,11 @@ public class OidList implements Streamable
return buf.toString();
}
+ public Iterator iterator ()
+ {
+ return new OidIterator();
+ }
+
private void expand ()
{
int[] oids = new int[_oids.length*2];
@@ -155,6 +164,30 @@ public class OidList implements Streamable
_oids = oids;
}
+ protected class OidIterator
+ implements Iterator
+ {
+ public boolean hasNext ()
+ {
+ return _index < size();
+ }
+
+ public Integer next ()
+ {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return get(_index++);
+ }
+
+ public void remove ()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected int _index = 0;
+ }
+
private int[] _oids;
private int _size;