mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 16:10:45 +03:00
Fix issue 13594: next(Even)Permutation doesn't need to take input range by ref.
This commit is contained in:
parent
947a526393
commit
ef2e43181b
1 changed files with 18 additions and 2 deletions
|
@ -13228,7 +13228,7 @@ do
|
||||||
* permutation; otherwise returns true.
|
* permutation; otherwise returns true.
|
||||||
*/
|
*/
|
||||||
bool nextPermutation(alias less="a<b", BidirectionalRange)
|
bool nextPermutation(alias less="a<b", BidirectionalRange)
|
||||||
(ref BidirectionalRange range)
|
(BidirectionalRange range)
|
||||||
if (isBidirectionalRange!BidirectionalRange &&
|
if (isBidirectionalRange!BidirectionalRange &&
|
||||||
hasSwappableElements!BidirectionalRange)
|
hasSwappableElements!BidirectionalRange)
|
||||||
{
|
{
|
||||||
|
@ -13403,6 +13403,14 @@ bool nextPermutation(alias less="a<b", BidirectionalRange)
|
||||||
assert(a == [3,2,1]);
|
assert(a == [3,2,1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 13594
|
||||||
|
@safe unittest
|
||||||
|
{
|
||||||
|
int[3] a = [1,2,3];
|
||||||
|
assert(nextPermutation(a[]));
|
||||||
|
assert(a == [1,3,2]);
|
||||||
|
}
|
||||||
|
|
||||||
// nextEvenPermutation
|
// nextEvenPermutation
|
||||||
/**
|
/**
|
||||||
* Permutes $(D range) in-place to the next lexicographically greater $(I even)
|
* Permutes $(D range) in-place to the next lexicographically greater $(I even)
|
||||||
|
@ -13466,7 +13474,7 @@ do
|
||||||
* permutation; otherwise returns true.
|
* permutation; otherwise returns true.
|
||||||
*/
|
*/
|
||||||
bool nextEvenPermutation(alias less="a<b", BidirectionalRange)
|
bool nextEvenPermutation(alias less="a<b", BidirectionalRange)
|
||||||
(ref BidirectionalRange range)
|
(BidirectionalRange range)
|
||||||
if (isBidirectionalRange!BidirectionalRange &&
|
if (isBidirectionalRange!BidirectionalRange &&
|
||||||
hasSwappableElements!BidirectionalRange)
|
hasSwappableElements!BidirectionalRange)
|
||||||
{
|
{
|
||||||
|
@ -13562,6 +13570,14 @@ bool nextEvenPermutation(alias less="a<b", BidirectionalRange)
|
||||||
assert(b == [ 1, 3, 2 ]);
|
assert(b == [ 1, 3, 2 ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@safe unittest
|
||||||
|
{
|
||||||
|
// Issue 13594
|
||||||
|
int[3] a = [1,2,3];
|
||||||
|
assert(nextEvenPermutation(a[]));
|
||||||
|
assert(a == [2,3,1]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Even permutations are useful for generating coordinates of certain geometric
|
Even permutations are useful for generating coordinates of certain geometric
|
||||||
shapes. Here's a non-trivial example:
|
shapes. Here's a non-trivial example:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue