-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two small feature requests #1
base: master
Are you sure you want to change the base?
Conversation
…ersal, with minimum and next(), and also, the ability to delete a node if you have the node in your hand (and not by key).
…e Node object, and not the tree.
…s to return the new internal node, and we can squirrel it away as we see fit outside of the Tree class.
Ah shoot, I forgot that pushes to my branch still show up in yours. I definitely didn't mean for that last commit (the change to package.json) to get to your repo. Sorry about that. |
Awesome...love the |
For example a list of events keyed by completion time, like how node The example code might look like: var x = events.minimum();
var y;
while (x && x.key < Date.now()) {
y = x.next();
tree.delete_node(x);
// do something with x.value
x = y;
} Thanks!
|
As is, I don't think duplicate keys are allowed. In the use case above couldn't the values just be an array of events that complete at the same time (specified by the key)? |
By default this option is off, to maintain backwards comptability. Provide some test cases to test both modes of operation
Also, while we're at it, clean up the tests a bit, and assert balance in a bunch of places we weren't doing so before.
Good point about insert clobbering repeated keys, I didn't see that. There's now an option to the If you want to store duplicate keys as an array of values, is the onus then on the user to make that happen? I.e, every insert then becomes a lookup and then an insert if the lookup fails? Doable, but it does double the number of traversals. There's also something a little bit unsettling when it comes to depending on strict equality of keys, especially for floats that can show rounding error. For hash tables, I agree, this isn't a concern, but for red-black trees, which are useful for storing values keyed by continuous keys, it's a common case. Why bother worrying about equality if you don't need to? |
Hi, Thanks for this package. I have two small feature requests:
next()
iteratively to traverse the tree in-order. You can stop whenever you'd like (which isn't the case for the existingforEach
). Also, unlike the existingforEach
, the implementation is iterative and not recursive.delete
into two small functions, and also the returnnewNode
frominsert
.Test code included for these newfeatures. Thanks.