Closed
Description
Hi @aureooms, I've been using your Finger tree javascript implementation in an online calculator that I'm building and so far it has been really good and easy to use. However today I found that I needed to iterate through the items of a tree from right to left and realized this was gonna be really difficult to do efficiently without changing your fingertree code.
Would it be possible to add something like an Tree#reverseIter()
method or something like it to the tree API that'll efficiently iterate through the tree from right to left like Tree[Symbol.iterator]()
does from left to right?
I'm guessing part of the implementation will probably look something like
Deep.prototype.reverseIter = function* () {
yield* this.left.reverseIter();
for (const node of reversed(this.middle)) yield* node.reverseIter();
yield* this.right.reverseIter();
};
but I'm not familiar enough with the code to be sure of the details.