F # equivalent to SortedDictionary from C #

new to F # I need to store a bunch of object lists according to float where the collection of lists is sorted according to float. I know that in C # I would use

SortedDictionary<float, List<obj>>


as the implementation is a red black tree allowing input and search in log (n). But what is the best way to attack the situation in F #. I tried using SortedDitionary, but I can't reference SortedDictionary [int] to find the value, so it makes it essentially useless (I could be wrong).

thanks for the help


source to share

3 answers




then it works as you would expect



The first tiger to do is read Okasaki's book Purely Functional Data Structures

This has ML implementations that can help you



You can use sorteddictionary.[int]

as John Palmer said, but it might be worth noting that the F # standard library includes a purely functional sorted collection of dictionaries called Map




All Articles