I am trying to generate an array of Names.
The names are retrieved from a database where they are sorted by enumerators, seen here:
How many Names to put into the new array? That depends on a Map, where key = Enum / value = int, seen here:
So for example, the map might tell us that from group A we should grab 2 names, and from group B we grab 4 names.
There should be no duplicate names.
What I have done is get the keys of the map (the enumerator which determines the “group”), and For Each group, find the map value (the int which determine show many names to select).
That int determines the length of a ForLoop, which is used to get random names from the Group:
Now, the problem occurs when I want to check for duplicates. If there is a duplicate, I should discard it and run the loop again. But how do I control the iteration of the for loop indexes?
I can think of a few “hacky” ways, like just chopping the array to length after the for loop, but there is probably a way I can be more explicit to just get the desired numbers?
Any advice is appreciated!