projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add FastSet.first() for quick access to the first element of a FastSet
[sbp.git]
/
src
/
edu
/
berkeley
/
sbp
/
util
/
FastSet.java
diff --git
a/src/edu/berkeley/sbp/util/FastSet.java
b/src/edu/berkeley/sbp/util/FastSet.java
index
4e289cd
..
581886e
100644
(file)
--- a/
src/edu/berkeley/sbp/util/FastSet.java
+++ b/
src/edu/berkeley/sbp/util/FastSet.java
@@
-22,6
+22,12
@@
public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T>, Visitable
return (T)array[i];
}
return (T)array[i];
}
+ public T first() {
+ if (only != null) return only;
+ if (array != null) return (T)(array[0]);
+ return null;
+ }
+
public FastSet() { }
public FastSet(T t) { only = t; }
public FastSet(Set<T> s) {
public FastSet() { }
public FastSet(T t) { only = t; }
public FastSet(Set<T> s) {