Intersection of two sets
sascha.orlov at gmail.com
Tue Dec 3 13:55:51 UTC 2019
On Tuesday, 3 December 2019 at 13:43:26 UTC, Jan Hönig wrote:
> 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
> 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.
> 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]`?
This depends on the available accesses on your sets. In terms of
Are your sets InputRanges, ForwardRange, ... ?
> 2) Are there some build-in function for handling such sets?
This is maybe what you are looking for:
More information about the Digitalmars-d-learn