So I run simple example of NativeMultiHashMap
multiHashMap.Add ( 0, 0 ) ;
multiHashMap.Add ( 0, 0 ) ;
multiHashMap.Add ( 0, 1 ) ;
multiHashMap.Add ( 0, 2 ) ;
multiHashMap.Add ( 1, 0 ) ;
multiHashMap.Add ( 1, 0 ) ;
multiHashMap.Add ( 1, 1 ) ;
multiHashMap.Add ( 1, 3 ) ;
Probably I misunderstand purpose of MultiHashMap, but I had impression, it should not store duplicates, just like NativeHashMap does not.
So my test returns
For multiHashMap.TryGetFirstValue ( 0, out item, out it ) ;
2,1,0
multiHashMap.TryGetFirstValue ( 1, out item, out it ) ;
3,1,0,0
I really expected only unique values. So in second case, only 3 values (3,1,0).
But there are 4 instead. (Maybe that is by design).
So far I understand, to find unique values, to ensure I don’t add duplicates, I need iterate through results first, for given key. Then check for existence of the value.
Is that expected result?
If so, what is best approach, to store only unique values, for given key?
Of course I can use Set, if I want override value in a key, for any reason.
In case I TryAdd values for a key in NativeHashMap, only first attempt of adding is stored for given key.
so
nativeHashMap.TryAdd ( 0, 1 ) ;
nativeHashMap.TryAdd ( 0, 2 ) ;
nativeHashMap.TryAdd ( 0, 2 ) ;
result for key 0 will return value 1.
This is what I expect, storing first value, for a key and that is ok.