why when table.Count = 1 table iteration functions get more than 1 key-value pairs? And if this is feature how can I expected behavior?
//
let table = new HashMultiMap<string, int> (HashIdentity.Structural)
table.Add("a", 1)
table.Add("a", 1)
table.Add("a", 1)
// now table.Count is one
let reduced = table.Fold (fun k v acc -> (k,v) :: acc) []
let acc = ref []
table.Iterate (fun k v -> acc.contents <- (k,v) :: acc.contents)
//
reduced and acc.contents contains three ("a",1) pairs
The documentation for the
Count
member says:If you have multiple values associated with the same key, there is still only a single key, so the value 1 is the expected result for your example. As far as I can see, there is no property that returns the total number of values, but you can implement that easily using
Fold
: