Conversation
Supports: Constructor with custom key and less-than functions add(), shift() and pop() between O(log16 N) and O(log32 N) ES6 iteration at O(N) first() and last() at O(1) Many other functions are either absent or will crash when run. See my pull request for more information.
|
I may not be the best person for now to help, but I will try : __hash
transducerthe iterator
testingautomated tests should be easier now with the oss fork merged, you should be able to run with list sizecorrect list size : according to the conference, I would guess 32 too, but that's really just guessing license and attributionimmutable-js has now been splitted from facebook and is now under MIT license. There is no facebook CLA to sign anymore. About the attribution, there is no special attribution for now, but I think you are right that it's something that we should discuss. I add your PR to the 4.1 milestone, as it is not required in 4.0, but it can be in here if your PR is ready to merge namingOne last think that troubles me : the name You mentioned that only operation can be done at the start or the end of the queue, which makes me thinks that it's more a |
This adds a new data type to immutable-js named SortedList, a Collection.Set subtype. Addresses #1791. My description in the docs:
This patch is usable in practice, but is not ready to be merged. add(), first(), last(), shift(), pop() and ES6 iterate all work but other functions either are absent or retain the List.js implementation and will error.
SortedList works using a tree of list-of-lists, like List.js, but because insertion is at arbitrary location by design, instead of all nodes being kept full the list-max is treated as a maximum and if a node tries to exceed the maximum it splits into two halves. Because the node list length is variable, each node tracks the minimum and maximum value in its branch of the tree to make navigation possible. Pointers are maintained to the least and greatest leaf nodes for constant first/last value access.
For my own amusement, and because I have had trouble getting the immutable-js automated tests to run, I wrote a standalone Preact app for testing and debugging SortedList:
To use this, check out both the sortedlist-pr branch and the test app, run
npm run buildin the sortedlist-pr dir, and runnpm link ../path/to/sortedlistin the test app dir.To test SortedList before submitting this PR, I temporarily reduced the node list max size to 4 and used this app to run 40,000 random operations on a list while verifying invariants (list is in sorted order; node min and max memos are accurate; head and tail point to actual head and tail) at each step.
Here are the issues that I think need to be resolved before accepting this PR:
Here are some things I think would be “nice to have” when including this in a release:
Here are the things I think I need help with:
__hash?@@transducer? How do I implement it? (The immutable-js-oss folks are helping me with this.)__iteratorand__iterate? What protocol do implementations of these two functions follow? (I think I understand__iteratorbut not whether “type 2” is mandatory, and I don’t understand what__iteratedoes.)I will also be submitting a version of this to immutable-js-oss. My working branch with non-squashed commits is here.