Iterate the values of a map
Updated
values() yields stored payloads, one per key. Duplicate values appear twice if two keys store them.
What to focus on
This is not a bag of original array items unless you built the map that way. Frequency-map values are counts, not the array.
Worked examples
three
a = [4, 1, 9] as {4:2,1:8,9:3}- values 2,8,3
Result: bag {2, 8, 3}
dup values
a = [4, 1] as {4:2,1:2}- two 2s
Result: 2 and 2
empty
a = []- no values
Result: nothing
Try it
Write valuesOf(m). m is the hash map. Return stored payloads, one per key. Duplicate values appear twice. Iteration order is unspecified. a = [4, 1, 9] as {4:2,1:8,9:3} → bag {2, 8, 3}. a = [4, 1] as {4:2,1:2} → 2 and 2. a = [] → nothing.
values are integers. Empty is in the cases. Iteration order is unspecified.