[Issue 15960] New: SetUnion should filter duplicates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Apr 26 20:47:57 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15960

          Issue ID: 15960
           Summary: SetUnion should filter duplicates
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: greensunny12 at gmail.com

Have a look at

http://en.cppreference.com/w/cpp/algorithm/merge
http://en.cppreference.com/w/cpp/algorithm/set_union

tl;dr: SetUnion should filter for duplicates

"The difference between these two algorithms is with handling values from both
input ranges which compare equivalent (see notes on LessThanComparable). If any
equivalent values appeared n times in the first range and m times in the
second, std::merge would output all n+m occurrences whereas std::set_union
would output std::max(n, m) ones only"


```
[1,2].merge([1,3]) == [1,1,2,3]
[1,2].setUnion([1,3]) == [1,2,3]
```

--


More information about the Digitalmars-d-bugs mailing list