mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
parent
9b5a54189d
commit
d0b9555a06
70 changed files with 222 additions and 222 deletions
|
@ -64,7 +64,7 @@ import std.range.primitives;
|
|||
import std.traits;
|
||||
// FIXME
|
||||
import std.meta : allSatisfy;
|
||||
import std.typecons; // : Flag, Tuple, tuple, Yes;
|
||||
import std.typecons; // : tuple, Tuple, Flag, Yes;
|
||||
|
||||
/**
|
||||
Find $(D value) _among $(D values), returning the 1-based index
|
||||
|
@ -852,7 +852,7 @@ range of range (of range...) comparisons.
|
|||
@safe unittest
|
||||
{
|
||||
import std.algorithm.comparison : equal;
|
||||
import std.range : chunks, iota;
|
||||
import std.range : iota, chunks;
|
||||
assert(equal!(equal!equal)(
|
||||
[[[0, 1], [2, 3]], [[4, 5], [6, 7]]],
|
||||
iota(0, 8).chunks(2).chunks(2)
|
||||
|
@ -925,7 +925,7 @@ range of range (of range...) comparisons.
|
|||
|
||||
@safe pure unittest
|
||||
{
|
||||
import std.utf : byChar, byDchar, byWchar;
|
||||
import std.utf : byChar, byWchar, byDchar;
|
||||
|
||||
assert(equal("æøå".byChar, "æøå"));
|
||||
assert(equal("æøå", "æøå".byChar));
|
||||
|
|
|
@ -21,7 +21,7 @@ version(unittest)
|
|||
|
||||
package string[] rndstuff(T : string)()
|
||||
{
|
||||
import std.random : Random, uniform, unpredictableSeed;
|
||||
import std.random : Random, unpredictableSeed, uniform;
|
||||
|
||||
static Random rnd;
|
||||
static bool first = true;
|
||||
|
@ -46,7 +46,7 @@ version(unittest)
|
|||
|
||||
package int[] rndstuff(T : int)()
|
||||
{
|
||||
import std.random : Random, uniform, unpredictableSeed;
|
||||
import std.random : Random, unpredictableSeed, uniform;
|
||||
|
||||
static Random rnd;
|
||||
static bool first = true;
|
||||
|
|
|
@ -2748,7 +2748,7 @@ if (fun.length >= 1)
|
|||
|
||||
alias binfuns = staticMap!(binaryFun, fun);
|
||||
static if (fun.length > 1)
|
||||
import std.typecons : isTuple, tuple;
|
||||
import std.typecons : tuple, isTuple;
|
||||
|
||||
/++
|
||||
No-seed version. The first element of $(D r) is used as the seed's value.
|
||||
|
@ -3219,7 +3219,7 @@ if (fun.length >= 1)
|
|||
// Sum all elements with explicit seed
|
||||
assert(arr.fold!((a, b) => a + b)(6) == 21);
|
||||
|
||||
import std.algorithm.comparison : max, min;
|
||||
import std.algorithm.comparison : min, max;
|
||||
import std.typecons : tuple;
|
||||
|
||||
// Compute minimum and maximum at the same time
|
||||
|
|
|
@ -78,7 +78,7 @@ T2=$(TR $(TDNW $(LREF $1)) $(TD $+))
|
|||
module std.algorithm.mutation;
|
||||
|
||||
import std.range.primitives;
|
||||
import std.traits : isArray, isBlitAssignable, isNarrowString, isSomeChar, Unqual;
|
||||
import std.traits : isArray, isBlitAssignable, isNarrowString, Unqual, isSomeChar;
|
||||
// FIXME
|
||||
import std.typecons; // : tuple, Tuple;
|
||||
|
||||
|
@ -279,7 +279,7 @@ Unicode integrity is not preserved:
|
|||
{
|
||||
import std.algorithm.comparison : equal;
|
||||
import std.conv : text;
|
||||
import std.random : Random, uniform, unpredictableSeed;
|
||||
import std.random : Random, unpredictableSeed, uniform;
|
||||
|
||||
// a more elaborate test
|
||||
{
|
||||
|
@ -845,7 +845,7 @@ See_Also:
|
|||
void initializeAll(Range)(Range range)
|
||||
if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range)
|
||||
{
|
||||
import core.stdc.string : memcpy, memset;
|
||||
import core.stdc.string : memset, memcpy;
|
||||
import std.traits : hasElaborateAssign, isDynamicArray;
|
||||
|
||||
alias T = ElementType!Range;
|
||||
|
@ -901,7 +901,7 @@ if (is(Range == char[]) || is(Range == wchar[]))
|
|||
///
|
||||
@system unittest
|
||||
{
|
||||
import core.stdc.stdlib : free, malloc;
|
||||
import core.stdc.stdlib : malloc, free;
|
||||
|
||||
struct S
|
||||
{
|
||||
|
@ -2835,7 +2835,7 @@ if (isInputRange!Range && hasLvalueElements!Range && is(typeof(range.front = val
|
|||
///
|
||||
nothrow @system unittest
|
||||
{
|
||||
import core.stdc.stdlib : free, malloc;
|
||||
import core.stdc.stdlib : malloc, free;
|
||||
|
||||
auto s = (cast(int*) malloc(5 * int.sizeof))[0 .. 5];
|
||||
uninitializedFill(s, 42);
|
||||
|
|
|
@ -41,10 +41,10 @@ module std.algorithm.setops;
|
|||
import std.range.primitives;
|
||||
|
||||
// FIXME
|
||||
import std.functional; // : binaryFun, unaryFun;
|
||||
import std.functional; // : unaryFun, binaryFun;
|
||||
import std.traits;
|
||||
// FIXME
|
||||
import std.meta; // : AliasSeq, allSatisfy, anySatisfy, staticMap;
|
||||
import std.meta; // : AliasSeq, staticMap, allSatisfy, anySatisfy;
|
||||
|
||||
import std.algorithm.sorting; // : Merge;
|
||||
import std.typecons : No;
|
||||
|
@ -82,13 +82,13 @@ auto cartesianProduct(R1, R2)(R1 range1, R2 range2)
|
|||
if (!allSatisfy!(isForwardRange, R1, R2) ||
|
||||
anySatisfy!(isInfinite, R1, R2))
|
||||
{
|
||||
import std.algorithm.iteration : joiner, map;
|
||||
import std.algorithm.iteration : map, joiner;
|
||||
|
||||
static if (isInfinite!R1 && isInfinite!R2)
|
||||
{
|
||||
static if (isForwardRange!R1 && isForwardRange!R2)
|
||||
{
|
||||
import std.range : chain, repeat, sequence, take, zip;
|
||||
import std.range : zip, repeat, take, chain, sequence;
|
||||
|
||||
// This algorithm traverses the cartesian product by alternately
|
||||
// covering the right and bottom edges of an increasing square area
|
||||
|
@ -107,13 +107,13 @@ if (!allSatisfy!(isForwardRange, R1, R2) ||
|
|||
}
|
||||
else static if (isInputRange!R1 && isForwardRange!R2 && !isInfinite!R2)
|
||||
{
|
||||
import std.range : repeat, zip;
|
||||
import std.range : zip, repeat;
|
||||
return joiner(map!((ElementType!R1 a) => zip(repeat(a), range2.save))
|
||||
(range1));
|
||||
}
|
||||
else static if (isInputRange!R2 && isForwardRange!R1 && !isInfinite!R1)
|
||||
{
|
||||
import std.range : repeat, zip;
|
||||
import std.range : zip, repeat;
|
||||
return joiner(map!((ElementType!R2 a) => zip(range1.save, repeat(a)))
|
||||
(range2));
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ void completeSort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
|||
if (hasLength!(RandomAccessRange2) && hasSlicing!(RandomAccessRange2))
|
||||
{
|
||||
import std.algorithm.mutation : bringToFront;
|
||||
import std.range : assumeSorted, chain;
|
||||
import std.range : chain, assumeSorted;
|
||||
// Probably this algorithm can be optimized by using in-place
|
||||
// merge
|
||||
auto lhsOriginal = lhs.release();
|
||||
|
@ -619,7 +619,7 @@ if (isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range)
|
|||
{
|
||||
assert(pivot < r.length || r.length == 0 && pivot == 0);
|
||||
if (r.length <= 1) return 0;
|
||||
import std.algorithm.mutation : move, swapAt;
|
||||
import std.algorithm.mutation : swapAt, move;
|
||||
alias lt = binaryFun!less;
|
||||
|
||||
// Pivot at the front
|
||||
|
@ -1939,7 +1939,7 @@ if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range ||
|
|||
{
|
||||
import std.algorithm.internal : rndstuff;
|
||||
import std.algorithm.mutation : swapRanges;
|
||||
import std.random : Random, uniform, unpredictableSeed;
|
||||
import std.random : Random, unpredictableSeed, uniform;
|
||||
import std.uni : toUpper;
|
||||
|
||||
// sort using delegate
|
||||
|
@ -2038,7 +2038,7 @@ if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range ||
|
|||
|
||||
private void quickSortImpl(alias less, Range)(Range r, size_t depth)
|
||||
{
|
||||
import std.algorithm.comparison : max, min;
|
||||
import std.algorithm.comparison : min, max;
|
||||
import std.algorithm.mutation : swap, swapAt;
|
||||
|
||||
alias Elem = ElementType!(Range);
|
||||
|
@ -2736,7 +2736,7 @@ private template TimSortImpl(alias pred, R)
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
import std.random : Random, randomShuffle, uniform;
|
||||
import std.random : Random, uniform, randomShuffle;
|
||||
|
||||
// Element type with two fields
|
||||
static struct E
|
||||
|
@ -2893,7 +2893,7 @@ schwartzSort(alias transform, alias less = "a < b",
|
|||
if (isRandomAccessRange!R && hasLength!R)
|
||||
{
|
||||
import std.conv : emplace;
|
||||
import std.range : SortedRange, zip;
|
||||
import std.range : zip, SortedRange;
|
||||
import std.string : representation;
|
||||
|
||||
alias T = typeof(unaryFun!transform(r.front));
|
||||
|
@ -3437,7 +3437,7 @@ private T[] randomArray(Flag!"exactSize" flag = No.exactSize, T = int)(
|
|||
T minValue = 0, T maxValue = 255)
|
||||
{
|
||||
import std.algorithm.iteration : map;
|
||||
import std.random : Random, uniform, unpredictableSeed;
|
||||
import std.random : unpredictableSeed, Random, uniform;
|
||||
auto size = flag == Yes.exactSize ? maxSize : uniform(1, maxSize);
|
||||
return iota(0, size).map!(_ => uniform(minValue, maxValue)).array;
|
||||
}
|
||||
|
@ -3698,7 +3698,7 @@ if (isInputRange!(SRange) && isRandomAccessRange!(TRange)
|
|||
|
||||
@system unittest
|
||||
{
|
||||
import std.random : Random, randomShuffle, uniform, unpredictableSeed;
|
||||
import std.random : Random, unpredictableSeed, uniform, randomShuffle;
|
||||
import std.typecons : Yes;
|
||||
|
||||
auto r = Random(unpredictableSeed);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue