checkpoint
[sbp.git] / src / edu / berkeley / sbp / util / FastSet.java
index a433b7c..086f636 100644 (file)
@@ -1,7 +1,7 @@
 package edu.berkeley.sbp.util;
 import java.util.*;
 
-public final class FastSet<T> implements Iterator<T>, Iterable<T> {
+public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T> {
 
     public static final int INITIAL_SIZE = 128;
 
@@ -14,6 +14,11 @@ public final class FastSet<T> implements Iterator<T>, Iterable<T> {
     public void        remove()   { throw new Error(); }
     public boolean     hasNext()  { return only==null ? i<size : i<1; }
     public T           next()     { return only==null ? (T)array[i++] : (i++)==0 ? only : null; }
+    public T get(int i) {
+        if (i==0 && only!=null) return only;
+        if (array==null) return null;
+        return (T)array[i];
+    }
 
     public FastSet() { }
     public FastSet(T t) { only = t; }