-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Sorted map please! #88
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
Comments
Yes! I want to build this and SortedSet. |
+100 |
Just figured out I need this. +1 from me. |
+1 indeed |
π |
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed. |
Sorted map would be great! π |
Also, an |
That would be so useful! |
Agreed. If I understand correctly const map = OrdererMap({a: 'a', c: 'c'});
const sorted = map.set('b', 'b').sort(); // Creates two copies. |
For prior art on this issue, Clojure(script)'s sorted-map implementation uses a persistent red-black tree:
There's a JavaScript implementation of the same data structure here that might be useful, too. Clojure's sorted-set uses the same data structure, slightly wrapped: https://github.com/clojure/clojure/blob/clojure-1.7.0/src/jvm/clojure/lang/PersistentTreeSet.java |
RB Tree sounds like the right way to do this. I'm putting this up for grabs for any adventurous contributors. Best way to learn about Persistent Immutable data structures is to implement them! |
Have not used yet but this SortedMap seems promising. |
@akagomez Want to take a crack at RB Tree implementation? |
Tempting @crodriguez1a. I've done a bunch of work with Red-Black Binary Tree's for CanJS (https://github.com/canjs/can-binarytree), based on a fork of this repo: https://github.com/vadimg/js_bintrees Leveraging that RB Tree implementation again should make this a less daunting task. If nobody disagrees with this approach I don't mind taking a crack at it with @crodriguez1a's help. |
@akagomez feel free to steal from my toy SortedMap (api not fully implemented) that I started for a side project: https://github.com/rongierlach/immutable-sorted-map/ It is using a regular BST under the hood, am intending to convert it to RB later on. |
The long wait is over. Have a look at our immutable-js fork with highly optimized implementation of SortedMap and SortedSet. Current version is using classic B-trees. https://github.com/applitopia/immutable-sorted |
Darn, I was looking forward to playing with this myself. Maybe @crodriguez1a and I can help convert @applitopia's implementation to use RB-trees. |
@applitopia - please consider contributing those implementations to this project! |
For reference if you want to adapt it, or as an alternative solution, my own immutable collections library has (among others) a sorted map, a sorted set and a red-black tree. The sorted map/set collections behave like Immutable.js' ordered equivalents by default, or you can supply a custom sorting predicate to have them sort their elements however you like. https://github.com/frptools/collectable |
Need this too! Thanks |
A map that inserts new items in the correct position, providing a custom sort function on the keys.
Would be nice. Otherwise, I can do fine with keeping a key array for the sorting, and a map myself.
The text was updated successfully, but these errors were encountered: