Anyone come up with some cool algorithms/templates for D lately?
BCS
ao at pathlink.com
Thu Apr 17 22:24:18 PDT 2008
Reply to janderson,
> In the past people have posted these cool algorithms/templates they
> figured out how to do in some neat way with D. Things like wow, this
> would take INF+ lines in C++ but I can do it in 2 in D. This seems
> to have died down a bit. I always found these topics most
> interesting.
>
> So I'm requesting people to post "cool stuff" they figured out how to
> do in D.
>
> -Joel
>
// Sort data using keys as the order
uint[] keys, data;
assert(keys.length == data.length);
ulong[] arr;
arr.length = keys.length;
foreach(int i, uint _; keys) arr[i] = (cast(uint)keys[i])<<32 | data[i];
arr.sort;
foreach(int i, uint _; keys) data[i] = cast(uint)(arr & 0x0ffff_ffff);
More information about the Digitalmars-d
mailing list