diff options
-rw-r--r-- | examples/search.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/search.js b/examples/search.js index 73f29d0..a1dcc7c 100644 --- a/examples/search.js +++ b/examples/search.js @@ -48,11 +48,23 @@ function Search(searchBlock){ // searchBlock should be a Space object. // until sort[ind][inds[ind]][ind] != sort[ind][otherind][ind]. // on each, if sort[ind][otherind][1-ind] == sort[ind][inds[ind]][1-ind], // add to adjacent and search it with exclude=adjacent. Add that to adjacent - let addr = inds[ind]; + let sort = this.sort[ind]; + let chkind = inds[ind]; + [-1, 1].forEach( sgn => { + let curind = chkind + sgn; + while (sort[curind] && sort[chkind][ind] == sort[curind][ind]){ + if (! exclude.has(sort[curind])){ + adjacent.add(...this.block(sort[curind], [curind, bs(sort, sort[curind], getComp(1-ind))], adjacent)); + } + curind += sgn; + } + }); + /*let thisaddr = this.sort[ind][inds[ind]]; for (let i = -1; i <= 1; i+=2) for (let j = 1; this.sort[ind][inds[ind]+i*j] && this.sort[ind][inds[ind]][ind] == this.sort[ind][inds[ind]+i*j][ind]; j++){ + let otheraddr = this.sort[ind][inds[ind]+i*j]; if (! exclude.has(this.sort[ind][inds[ind]]) && this.sort[ind][inds[ind]][1-ind] == this.sort[inds[ind]+i*j][1-ind]){ // Make more readable adjacent.add(...this.block(this.sort[ind][inds[ind]+i*j], inds[ind+i*j], exclude=adjacent)); // Already includes itself - }} + }}*/ }); return adjacent; } |