digitalmars.D.learn - Set Operations on Set-like Containers
- =?UTF-8?B?Tm9yZGzDtnc=?= (9/9) Nov 02 2016 Does
- =?UTF-8?B?Tm9yZGzDtnc=?= (7/9) Nov 02 2016 A typical use case is intersection of the two sets `x` and `y`.
- Andrei Alexandrescu (4/11) Nov 02 2016 Currently we don't have a good framework for associative ranges yet. We
Does https://dlang.org/phobos/std_algorithm_setops.html support specializations when (some) arguments are containers/ranges that provide the `in` operator? Typically set- and map-like containers with O(1) key membership checking. If not, should they? And what about operator overloading for union (|), intersection (&) and difference (-)?
Nov 02 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)`.
Nov 02 2016
On 11/02/2016 11:07 AM, Nordlöw wrote:On Wednesday, 2 November 2016 at 13:45:41 UTC, Nordlöw wrote:Currently we don't have a good framework for associative ranges yet. We should define what the associative operations are, and then we can proceed to see where they'd make sense. -- AndreiTypically 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)`.
Nov 02 2016