Re: Intersection of two sets

2019-12-06 Thread Jan Hönig via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 08:01:59 UTC, Per Nordlöw wrote: On Tuesday, 3 December 2019 at 13:43:26 UTC, Jan Hönig wrote: pseudocode: alias set = bool[] set foo = ... set bar = ... set result; One simple optimization is to set* smallest; set* largest; if (foo.length < bar.length) {

Re: Intersection of two sets

2019-12-04 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 13:43:26 UTC, Jan Hönig wrote: pseudocode: alias set = bool[] set foo = ... set bar = ... set result; One simple optimization is to set* smallest; set* largest; if (foo.length < bar.length) { smallest = &foo; largest = &bar; } else { smallest = &bar;

Re: Intersection of two sets

2019-12-03 Thread mipri via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 18:45:18 UTC, Jan Hönig wrote: On Tuesday, 3 December 2019 at 13:55:51 UTC, Alex wrote: This depends on the available accesses on your sets. In terms of ranges: Are your sets InputRanges, ForwardRange, ... ? 2) Are there some build-in function for handling su

Re: Intersection of two sets

2019-12-03 Thread Jan Hönig via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 13:55:51 UTC, Alex wrote: This depends on the available accesses on your sets. In terms of ranges: Are your sets InputRanges, ForwardRange, ... ? 2) Are there some build-in function for handling such sets? This is maybe what you are looking for: https://dla

Re: Intersection of two sets

2019-12-03 Thread Jan Hönig via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 15:14:03 UTC, ikod wrote: Never tried, but depending of the nature of your "something" you can try bit sets. There are efficient algorithms for large bit arrays (see "roaring" for example). "roaring" is massive overkill for my case, but thanks for suggesting i

Re: Intersection of two sets

2019-12-03 Thread ikod via Digitalmars-d-learn
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[]`). And i want to join them, via an intersection. I know how to code t

Re: Intersection of two sets

2019-12-03 Thread Alex via Digitalmars-d-learn
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[]`). And i want to join them, via an intersection. I know how to code t