projects
/
sbp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
476b0f2
)
optimizations to FastSet: make it final again, don't shift the contents of the entire...
author
adam
<adam@megacz.com>
Tue, 4 Mar 2008 04:06:52 +0000
(23:06 -0500)
committer
adam
<adam@megacz.com>
Tue, 4 Mar 2008 04:06:52 +0000
(23:06 -0500)
darcs-hash:
20080304040652
-5007d-
c684bcc1dcca5f98a8cd8122314a3633157e7bd4
.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
581886e
..
289e5ec
100644
(file)
--- a/
src/edu/berkeley/sbp/util/FastSet.java
+++ b/
src/edu/berkeley/sbp/util/FastSet.java
@@
-3,7
+3,7
@@
package edu.berkeley.sbp.util;
import java.util.*;
package edu.berkeley.sbp.util;
import java.util.*;
-public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T>, Visitable<T> {
+public final class FastSet<T> implements Iterator<T>, Iterable<T>, Visitable<T> {
public static final int INITIAL_SIZE = 8;
public static final int INITIAL_SIZE = 8;
@@
-42,11
+42,16
@@
public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T>, Visitable
return;
}
boolean found = false;
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--;
+ int j;
+ for(j=0; j<size; j++)
+ if (array[j]==t) {
+ found = true;
+ break;
+ }
+ if (!found) return;
+ array[j] = array[size-1];
+ array[size-1] = null;
+ size--;
}
public <B,C> void visit(Invokable<T,B,C> ivbc, B b, C c) {
}
public <B,C> void visit(Invokable<T,B,C> ivbc, B b, C c) {