Set Operations on Set-like Containers

Nordlöw via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 2 08:07:29 PDT 2016


On Wednesday, 2 November 2016 at 13:45:41 UTC, Nordlöw wrote:
> Typically set- and map-like containers with O(1) key membership 
> checking.

A typical use case is intersection of the two sets `x` and `y`.

When `x` and `y` both support O(1)-`contains(e)` the preferred 
algorithm is to interate over all elements in the shorter 
(smallest .length) of `x` and `y` (called `s`), and return only 
those elements of type E in `s` than can be looked up in `l` via 
`l.contains(E)`.


More information about the Digitalmars-d-learn mailing list