Permutations: Difference between revisions

updated faster D entry
(updated faster D entry)
Line 865:
this (/*in*/ T[] items) /*pure*/ nothrow
in {
static immutableenum string L = text(indexes.length); // impure
assert(items.length >= 0 && items.length <= indexes.length,
"Permutations: items.length must be >= 0 && < " ~ L);
Line 883:
}
 
@property T[] front() /*const*/ pure /*nothrow*/ {
static if (doCopy)
//return items.dup; // not nothrow
return items ~ []; // slower
else
return items;
Line 894 ⟶ 895:
}
 
void popFront() /*pure nothrow*/ {
tot--;
if (tot > 0) {
Line 931 ⟶ 932:
version (permutations2_main) {
void main() {
import std.stdio, std.bigint;
foreach (p; permutations!false([1, 2, 3]))
writeln(p);
alias BigInt B;
foreach (p; permutations!false([B(1), B(2), B(3)])) {}
}
}</lang>