Skip to content

Commit

Permalink
Small modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
patmorin committed Jan 27, 2012
1 parent e5e4b36 commit 99ce6c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
16 changes: 0 additions & 16 deletions java/ods/BinaryTrie.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ public BinaryTrie(Node sampleNode, Integerizer<T> it) {
n = 0;
}

protected class Location {
int i;
Node u;
}

public String toString() {
return Utils.collectionToString(this);
}
Expand Down Expand Up @@ -176,17 +171,6 @@ public T find(T x) {
return u == dummy ? null : u.x;
}

protected Node findLeaf(int ix) {
int i = 0, c;
Node u = r;
for (i = 0; i < w; i++) {
c = (ix >>> w-i-1) & 1;
if (u.child[c] == null) return null;
u = u.child[c];
}
return u;
}

public boolean remove(T x) {
// 1 - find leaf, u, containing x
int i = 0, c, ix = it.intValue(x);
Expand Down
7 changes: 4 additions & 3 deletions java/ods/YFastTrie.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ public int intValue(Pair<T> p) {
}

public boolean add(T x) {
STreap<T> t = xft.find(new Pair<T>(it.intValue(x))).t;
int ix = it.intValue(x);
STreap<T> t = xft.find(new Pair<T>(ix)).t;
if (t.add(x)) {
n++;
if (rand.nextInt(w) == 0) {
STreap<T> t1 = t.split(x);
xft.add(new Pair<T>(it.intValue(x), t1));
xft.add(new Pair<T>(ix, t1));
}
return true;
}
Expand Down Expand Up @@ -143,7 +144,7 @@ public boolean remove(T x) {
Node<T> u = xft.findNode(ix);
boolean ret = u.x.t.remove(x);
if (ret) n--;
if (u != null && u.x.x == ix && ix != 0xffffffff) {
if (u.x.x == ix && ix != 0xffffffff) {
STreap<T> t2 = u.child[1].x.t;
t2.absorb(u.x.t);
xft.remove(u.x);
Expand Down

0 comments on commit 99ce6c6

Please sign in to comment.