Bug 4607 – Make .byValue() and .byKey() of associative arrays adopt the input range interface.
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-08-09T10:26:00Z
Last change time
2012-01-17T14:06:29Z
Assigned to
sean
Creator
kennytm
Comments
Comment #0 by kennytm — 2010-08-09T10:26:46Z
Currently .byValue() and .byKey() returns a delegate. This make it only iterable by foreach, but cannot be used in std.algorithm algorithms, e.g.
----
import std.algorithm;
import std.stdio;
void main () {
auto x = ["a":4, "b":6];
writeln( reduce!"a+b"( map!"a*a"( x.byValue() ) ) );
}
----
While it is possible to use .values and .keys, both of these create a copy of the array, which is unnecessary for many codes like the one above.
Comment #1 by bearophile_hugs — 2012-01-17T14:05:16Z
*** Issue 7148 has been marked as a duplicate of this issue. ***
Comment #2 by bearophile_hugs — 2012-01-17T14:06:29Z