fsharp-hashcollections
fsharp-hashcollections copied to clipboard
How to create a `HashSet` from `seq` with a custom comparer?
Another function in the HashSet/Map to do so could work for your case? Something like:
let ofSeqWithComparer (s: #seq<KeyValuePair<'k, 'v>>) : HashMap<'k, 'v, 'tk> =
let eqComparer = new 'tk()
HashMap<_, _, _>(
HashTrie.ofSeq keyExtractor eqComparer s empty.HashTrieRoot,
eqComparer)
Then at usage site you could do:
let c : HashMap<_, _, 'comparerType> = data |> HashMap.ofSeqWithComparer