projects
/
sbp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7d6f753
)
added remove() method to FastSet
author
adam
<adam@megacz.com>
Mon, 30 Oct 2006 05:14:20 +0000
(
00:14
-0500)
committer
adam
<adam@megacz.com>
Mon, 30 Oct 2006 05:14:20 +0000
(
00:14
-0500)
darcs-hash:
20061030051420
-5007d-
62a3f5e8d0716791d990dd716f130d20dc75bb34
.gz
src/edu/berkeley/sbp/util/FastSet.java
patch
|
blob
|
history
diff --git
a/src/edu/berkeley/sbp/util/FastSet.java
b/src/edu/berkeley/sbp/util/FastSet.java
index
26c5f33
..
711c984
100644
(file)
--- a/
src/edu/berkeley/sbp/util/FastSet.java
+++ b/
src/edu/berkeley/sbp/util/FastSet.java
@@
-30,6
+30,19
@@
public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T>, Visitable
for(T t : s) array[size++] = t;
}
for(T t : s) array[size++] = t;
}
+ public void remove(T t) {
+ if (only != null) {
+ if (only==t) only=null;
+ return;
+ }
+ boolean found = false;
+ for(int j=0; j<size; j++) {
+ if (array[j]==t) found = true;
+ if (found && j<size-1) array[j] = array[j+1];
+ }
+ if (found) size--;
+ }
+
public <B,C> void visit(Invokable<T,B,C> ivbc, B b, C c) {
if (only!=null) ivbc.invoke(only, b, c);
else for(int j=0; j<size; j++)
public <B,C> void visit(Invokable<T,B,C> ivbc, B b, C c) {
if (only!=null) ivbc.invoke(only, b, c);
else for(int j=0; j<size; j++)