I am kind of lost on which data structure to use to solve my problem effectively. I want to map an array to a value. What I mean is that if I have 1000 values, I need to be able to map multiple other values to each of the 1000 values.
For example,
I have 1000 A values from 1-1000. For each value A, I want to map k other values B (these range from 1-1000 also). But I do want to ensure that whatever values are mapped to A are not duplicates. Mapped values between different A values can be the same (i.e. both 2 and 1000 have 67 mapped to them).
1 -> 138, 92, 835, 841, 12
2 -> 766, 324, 26, 933, 62
3 -> 53, 131, 62, 121, 67
4->160, 160 #NOT OK
4-> 162, 171, 594, 912, 455
...
1000->146, 981, 67, 246, 146
So when I look at some arbitrary value A, I should be easily able to identify whatever values are mapped to it. So if I wanted to access value 3, I should be able to print out both the value A (3) and its associated values (53, 131, 62, 121, 67).
I hope that makes sense. What would be the best way of achieving this kind of data structure? Any help of an explanation or an example would be much appreciated.