Intersection of two sets

Jan Hönig hrominium at gmail.com
Tue Dec 3 13:43:26 UTC 2019


It seems i don't google the right keywords.

What i want to do: I have two sets. (I didn't find how to do 
sets, so i have two associative boolean arrays 
`bool[<something>]`). And i want to join them, via an 
intersection.

I know how to code this. Loop over one AA, if the key is also in 
the other one, we add that to the third array which is going to 
be returned.

pseudocode:
alias set = bool[<something>]
set foo = ...
set bar = ...
set result;

foreach(key; foo)
{
   if (key in bar)
   {
     result[key] = true;
   }
}
return result;


1) Is there a better way for creating a set, other then `alias 
set = bool[keyClass]`?
2) Are there some build-in function for handling such sets?


More information about the Digitalmars-d-learn mailing list