Difference and purpose between NativeMultiHashMap vs NativeHashMap

I look inside Collection package and they have the same data and identical function.
With exception that NativeHashMap allow you to get value by key. While MultiHashMap only allow you to
GetFirst and GetNext value.

I do not have experience programming background. They both are dictionary to me.

Can anyone clarify how each of these use in what cases?

In short, NativeHashMap has 1 key and only 1 value. While NativeMultiHashMap has 1 key and multiple values (more than one possible).

1 Like

NativeHashMap - A normal dictionary mapping a key to a single value.

NativeMultiHashMap - A dictionary mapping a key to 1 or more values, like a list.

When iterating over the list of MultiHashMap you would use TryGetFirstValue, if that is true, use that value, then use TryGetNextValue until it is false.

3 Likes

While it’s already answered I find comparisons help so you could consider them to be similar to

Dictionary<TKey, TValue> -----> NativeHashMap
Dictionary<TKey, List> -----> NativeMultiHashMap

(internally they work a bit different, but this is kind of what they’re replacing)

5 Likes

NativeHashMap has all uses of Dictionary, you need to tie some value to another value.
MultiHashMap can be used for grouping things like in boid sample you hash positions of boids and then you have all boids from one secton under one hash.

I have spent probably far too long finding this as I have been really on the edge edging to use this for what I am doing.

1 Like

How would I set that up? Please help, I am trying to find out how it can be done, but I can’t seem to find a good way to update the values of the elements of a list under the key.