/* */ public void collide(Dispatcher dispatcher) /* */ { /* 96 */ this.sets[0].optimizeIncremental(1 + this.sets[0].leaves * this.dupdates / 100); /* 97 */ this.sets[1].optimizeIncremental(1 + this.sets[1].leaves * this.fupdates / 100); /* */ /* 100 */ this.stageCurrent = ((this.stageCurrent + 1) % 2); /* 101 */ DbvtProxy current = this.stageRoots[this.stageCurrent]; /* 102 */ if (current != null) { /* 103 */ DbvtTreeCollider collider = new DbvtTreeCollider(this); /* */ do { /* 105 */ DbvtProxy next = current.links[1]; /* 106 */ this.stageRoots[current.stage] = listremove(current, this.stageRoots[current.stage]); /* 107 */ this.stageRoots[2] = listappend(current, this.stageRoots[2]); /* 108 */ Dbvt.collideTT(this.sets[1].root, current.leaf, collider); /* 109 */ this.sets[0].remove(current.leaf); /* 110 */ current.leaf = this.sets[1].insert(current.aabb, current); /* 111 */ current.stage = 2; /* 112 */ current = next; /* 113 */ }while (current != null); /* */ } /* */ /* 118 */ DbvtTreeCollider collider = new DbvtTreeCollider(this); /* */ /* 121 */ Dbvt.collideTT(this.sets[0].root, this.sets[1].root, collider); /* */ /* 125 */ Dbvt.collideTT(this.sets[0].root, this.sets[0].root, collider); /* */ /* 132 */ ObjectArrayList pairs = this.paircache.getOverlappingPairArray(); /* 133 */ if (pairs.size() > 0) { /* 134 */ int i = 0; for (int ni = pairs.size(); i < ni; i++) { /* 135 */ BroadphasePair p = (BroadphasePair)pairs.getQuick(i); /* 136 */ DbvtProxy pa = (DbvtProxy)p.pProxy0; /* 137 */ DbvtProxy pb = (DbvtProxy)p.pProxy1; /* 138 */ if (!DbvtAabbMm.Intersect(pa.aabb, pb.aabb)) /* */ { /* 140 */ if (pa.hashCode() > pb.hashCode()) { /* 141 */ DbvtProxy tmp = pa; /* 142 */ pa = pb; /* 143 */ pb = tmp; /* */ } /* 145 */ this.paircache.removeOverlappingPair(pa, pb, dispatcher); /* 146 */ ni--; /* 147 */ i--; /* */ } /* */ } /* */ } /* */ /* 152 */ this.pid += 1; /* */ }
/** * Shifts left entries with the specified hash code, starting at the specified position, and * empties the resulting free entry. If any entry wraps around the table, instantiates lazily * {@link #wrapped} and stores the entry key. * * @param pos a starting position. * @return the position cleared by the shifting process. */ protected final int shiftKeys(int pos) { // Shift entries with the same hash. int last, slot; for (; ; ) { pos = ((last = pos) + 1) & mask; while (used[pos]) { slot = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode((K) (key[pos])))) & mask; if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break; pos = (pos + 1) & mask; } if (!used[pos]) break; if (pos < last) { // Wrapped entry. if (wrapped == null) wrapped = new ObjectArrayList<K>(); wrapped.add(key[pos]); } key[last] = key[pos]; value[last] = value[pos]; } used[last] = false; key[last] = null; return last; }
public int nextEntry() { if (!hasNext()) throw new NoSuchElementException(); c--; // We are just enumerating elements from the wrapped list. if (pos < 0) { final Object k = wrapped.get(-(last = --pos) - 2); // The starting point. int pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode((K) ((K) k)))) & mask; // There's always an unused entry. while (used[pos]) { if ((strategy.equals((key[pos]), (K) ((K) k)))) return pos; pos = (pos + 1) & mask; } } last = pos; // System.err.println( "Count: " + c ); if (c != 0) { final boolean used[] = Object2CharOpenCustomHashMap.this.used; while (pos-- != 0 && !used[pos]) ; // When here pos < 0 there are no more elements to be enumerated by scanning, but wrapped // might be nonempty. } return last; }
@SuppressWarnings("unchecked") public void remove() { if (last == -1) throw new IllegalStateException(); if (pos < -1) { // We're removing wrapped entries. Object2CharOpenCustomHashMap.this.remove(wrapped.set(-pos - 2, null)); last = -1; return; } size--; if (shiftKeys(last) == pos && c > 0) { c++; nextEntry(); } last = -1; // You can no longer remove this entry. if (ASSERTS) checkTable(); }