Anonymous user
K-d tree: Difference between revisions
Updated both D entries
m (→{{header|Perl 6}}: Use named params to make custom "new" method obsolete.) |
(Updated both D entries) |
||
Line 374:
typeof(return) result;
foreach (immutable i; 0 .. k)
result[i] = uniform
return result;
}
Line 418:
writefln("Visited an average of %0.2f nodes on %d searches " ~
"in %d ms.", visited /
}</lang>
{{out|Output, using the ldc2 compiler}}
Line 444:
template Iota(int stop) {
static if (stop <= 0)
alias Iota = TypeTuple!()
else
alias Iota = TypeTuple!(Iota!(stop - 1), stop - 1)
}
Line 548:
void randPt(size_t dim=3)(ref KdNode v, ref Xorshift rng) nothrow {
foreach (i; Iota!dim) {
v.x[i] = rng.front
rng.popFront
}
}
Line 593:
size_t sum = 0;
foreach (immutable _; 0 .. testRuns) {
found = null;
nVisited = 0;
Line 602:
writefln("\nBig tree:\n Visited %d nodes for %d random "~
"searches (%.2f per lookup).",
sum, testRuns, sum /
}
|