Looking for a little advice on leveraging AsParallel()
or Parallel.ForEach()
to speed this up.
See the method I\'ve got (simplified/bastardized
I would prefer to use another data structure like a Set for each alias and then use Set union to merge them.
Something like this
public string[] ExpandAliases(string[] countries){
// Alias definitions
var apac = new HashSet { "US", "FR", ...};
...
var aliases = new HashMap> { {"APAC": apac}, ... };
var expanded = new HashSet
foreach(var country in countries){
if(aliases.Contains(country)
expanded.Union(aliases[country]);
else{
expanded.Add(country);
}
return expanded.ToArray();
}
Note: code should be viewed as pseudo-code.