mirror of
https://github.com/dlang/phobos.git
synced 2025-05-14 08:55:54 +03:00
Remove package wide std.algorithm imports from Phobos
This commit is contained in:
parent
66f3456693
commit
67d44e4cdc
20 changed files with 43 additions and 37 deletions
|
@ -789,7 +789,7 @@ template equal(alias pred = "a == b")
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.math : approxEqual;
|
import std.math : approxEqual;
|
||||||
import std.algorithm : equal;
|
import std.algorithm.comparison : equal;
|
||||||
|
|
||||||
int[] a = [ 1, 2, 4, 3 ];
|
int[] a = [ 1, 2, 4, 3 ];
|
||||||
assert(!equal(a, a[1..$]));
|
assert(!equal(a, a[1..$]));
|
||||||
|
@ -815,7 +815,7 @@ range of range (of range...) comparisons.
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.range : iota, chunks;
|
import std.range : iota, chunks;
|
||||||
import std.algorithm : equal;
|
import std.algorithm.comparison : equal;
|
||||||
assert(equal!(equal!equal)(
|
assert(equal!(equal!equal)(
|
||||||
[[[0, 1], [2, 3]], [[4, 5], [6, 7]]],
|
[[[0, 1], [2, 3]], [[4, 5], [6, 7]]],
|
||||||
iota(0, 8).chunks(2).chunks(2)
|
iota(0, 8).chunks(2).chunks(2)
|
||||||
|
|
|
@ -3328,7 +3328,8 @@ The number of seeds must be correspondingly increased.
|
||||||
*/
|
*/
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : map, max, min;
|
import std.algorithm.comparison : max, min;
|
||||||
|
import std.algorithm.iteration : map;
|
||||||
import std.math : approxEqual;
|
import std.math : approxEqual;
|
||||||
import std.typecons : tuple;
|
import std.typecons : tuple;
|
||||||
|
|
||||||
|
@ -3347,7 +3348,7 @@ The number of seeds must be correspondingly increased.
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : equal, map, max, min;
|
import std.algorithm.comparison : equal, max, min;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.range : chain;
|
import std.range : chain;
|
||||||
import std.typecons : tuple;
|
import std.typecons : tuple;
|
||||||
|
@ -3406,7 +3407,6 @@ The number of seeds must be correspondingly increased.
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : map;
|
|
||||||
import std.math : approxEqual;
|
import std.math : approxEqual;
|
||||||
import std.typecons : tuple;
|
import std.typecons : tuple;
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,6 @@ auto cartesianProduct(R1, R2)(R1 range1, R2 range2)
|
||||||
// Issue 13091
|
// Issue 13091
|
||||||
pure nothrow @safe @nogc unittest
|
pure nothrow @safe @nogc unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : cartesianProduct;
|
|
||||||
int[1] a = [1];
|
int[1] a = [1];
|
||||||
foreach (t; cartesianProduct(a[], a[])) {}
|
foreach (t; cartesianProduct(a[], a[])) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1737,7 +1737,8 @@ class Base64Exception : Exception
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : sort, equal;
|
import std.algorithm.sorting : sort;
|
||||||
|
import std.algorithm.comparison : equal;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
|
|
@ -148,7 +148,8 @@ as the one being worked with. It is important to note that many generic range
|
||||||
algorithms return the same range type as their input range.
|
algorithms return the same range type as their input range.
|
||||||
|
|
||||||
---
|
---
|
||||||
import std.algorithm : equal, find;
|
import std.algorithm.comparison : equal;
|
||||||
|
import std.algorithm.iteration : find;
|
||||||
import std.container;
|
import std.container;
|
||||||
import std.range : take;
|
import std.range : take;
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ a member function, the documention usually refers to the parameter's templated
|
||||||
type as $(D Stuff).
|
type as $(D Stuff).
|
||||||
|
|
||||||
---
|
---
|
||||||
import std.algorithm : equal;
|
import std.algorithm.comparison : equal;
|
||||||
import std.container;
|
import std.container;
|
||||||
import std.range : iota;
|
import std.range : iota;
|
||||||
|
|
||||||
|
|
|
@ -755,7 +755,7 @@ auto csvReader(Contents = string,
|
||||||
|
|
||||||
@safe unittest // const/immutable dchars
|
@safe unittest // const/immutable dchars
|
||||||
{
|
{
|
||||||
import std.algorithm : map;
|
import std.algorithm.iteration : map;
|
||||||
import std.array : array;
|
import std.array : array;
|
||||||
const(dchar)[] c = "foo,bar\n";
|
const(dchar)[] c = "foo,bar\n";
|
||||||
assert(csvReader(c).map!array.array == [["foo", "bar"]]);
|
assert(csvReader(c).map!array.array == [["foo", "bar"]]);
|
||||||
|
@ -907,17 +907,18 @@ public:
|
||||||
{
|
{
|
||||||
static if (is(Contents T : T[U], U : string))
|
static if (is(Contents T : T[U], U : string))
|
||||||
{
|
{
|
||||||
import std.algorithm : sort;
|
import std.algorithm.sorting : sort;
|
||||||
sort(indices);
|
sort(indices);
|
||||||
}
|
}
|
||||||
else static if (ErrorLevel == Malformed.ignore)
|
else static if (ErrorLevel == Malformed.ignore)
|
||||||
{
|
{
|
||||||
import std.algorithm : sort;
|
import std.algorithm.sorting : sort;
|
||||||
sort(indices);
|
sort(indices);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
import std.algorithm : isSorted, findAdjacent;
|
import std.algorithm.searching : findAdjacent;
|
||||||
|
import std.algorithm.sorting : isSorted;
|
||||||
if (!isSorted(indices))
|
if (!isSorted(indices))
|
||||||
{
|
{
|
||||||
auto ex = new HeaderMismatchException
|
auto ex = new HeaderMismatchException
|
||||||
|
|
|
@ -256,7 +256,7 @@ version(ExampleDigest)
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
//Using the OutputRange feature
|
//Using the OutputRange feature
|
||||||
import std.algorithm : copy;
|
import std.algorithm.mutation : copy;
|
||||||
import std.range : repeat;
|
import std.range : repeat;
|
||||||
import std.digest.md;
|
import std.digest.md;
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ package template isDigestibleRange(Range)
|
||||||
DigestType!Hash digest(Hash, Range)(auto ref Range range) if (!isArray!Range
|
DigestType!Hash digest(Hash, Range)(auto ref Range range) if (!isArray!Range
|
||||||
&& isDigestibleRange!Range)
|
&& isDigestibleRange!Range)
|
||||||
{
|
{
|
||||||
import std.algorithm : copy;
|
import std.algorithm.mutation : copy;
|
||||||
Hash hash;
|
Hash hash;
|
||||||
hash.start();
|
hash.start();
|
||||||
copy(range, &hash);
|
copy(range, &hash);
|
||||||
|
@ -621,7 +621,7 @@ interface Digest
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
//Using the OutputRange feature
|
//Using the OutputRange feature
|
||||||
import std.algorithm : copy;
|
import std.algorithm.mutation : copy;
|
||||||
import std.range : repeat;
|
import std.range : repeat;
|
||||||
import std.digest.md;
|
import std.digest.md;
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ if (isDigest!H)
|
||||||
{
|
{
|
||||||
import std.digest.sha, std.digest.hmac;
|
import std.digest.sha, std.digest.hmac;
|
||||||
import std.string : representation;
|
import std.string : representation;
|
||||||
import std.algorithm : map;
|
import std.algorithm.iteration : map;
|
||||||
string data = "Hello, world";
|
string data = "Hello, world";
|
||||||
auto digest = data.representation
|
auto digest = data.representation
|
||||||
.map!(a => cast(ubyte)(a+1))
|
.map!(a => cast(ubyte)(a+1))
|
||||||
|
|
|
@ -1964,7 +1964,8 @@ auto handle(E : Throwable, RangePrimitive primitivesToHandle, alias handler, Ran
|
||||||
///
|
///
|
||||||
pure @safe unittest
|
pure @safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : equal, map, splitter;
|
import std.algorithm.comparison : equal;
|
||||||
|
import std.algorithm.iteration : map, splitter;
|
||||||
import std.conv : to, ConvException;
|
import std.conv : to, ConvException;
|
||||||
|
|
||||||
auto s = "12,1337z32,54,2,7,9,1z,6,8";
|
auto s = "12,1337z32,54,2,7,9,1z,6,8";
|
||||||
|
@ -1981,7 +1982,7 @@ pure @safe unittest
|
||||||
///
|
///
|
||||||
pure @safe unittest
|
pure @safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : equal;
|
import std.algorithm.comparison : equal;
|
||||||
import std.range : retro;
|
import std.range : retro;
|
||||||
import std.utf : UTFException;
|
import std.utf : UTFException;
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ class MultiLogger : Logger
|
||||||
*/
|
*/
|
||||||
Logger removeLogger(in char[] toRemove) @safe
|
Logger removeLogger(in char[] toRemove) @safe
|
||||||
{
|
{
|
||||||
import std.algorithm : copy;
|
import std.algorithm.mutation : copy;
|
||||||
import std.range.primitives : back, popBack;
|
import std.range.primitives : back, popBack;
|
||||||
for (size_t i = 0; i < this.logger.length; ++i)
|
for (size_t i = 0; i < this.logger.length; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1070,7 +1070,8 @@ template aliasSeqOf(alias range)
|
||||||
///
|
///
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : map, sort;
|
import std.algorithm.iteration : map;
|
||||||
|
import std.algorithm.sorting : sort;
|
||||||
import std.string : capitalize;
|
import std.string : capitalize;
|
||||||
|
|
||||||
struct S
|
struct S
|
||||||
|
|
|
@ -120,7 +120,7 @@ interface InputRange(E) {
|
||||||
///
|
///
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : map;
|
import std.algorithm.iteration : map;
|
||||||
import std.range : iota;
|
import std.range : iota;
|
||||||
|
|
||||||
void useRange(InputRange!int range) {
|
void useRange(InputRange!int range) {
|
||||||
|
@ -505,7 +505,7 @@ unittest
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.internal.test.dummyrange;
|
import std.internal.test.dummyrange;
|
||||||
import std.algorithm : equal;
|
import std.algorithm.comparison : equal;
|
||||||
import std.array;
|
import std.array;
|
||||||
|
|
||||||
static void testEquality(R)(iInputRange r1, R r2) {
|
static void testEquality(R)(iInputRange r1, R r2) {
|
||||||
|
|
|
@ -5134,7 +5134,8 @@ unittest
|
||||||
|
|
||||||
writefln("%(%s %|%)", iota(0, 5));
|
writefln("%(%s %|%)", iota(0, 5));
|
||||||
|
|
||||||
import std.algorithm : map, copy;
|
import std.algorithm.iteration : map;
|
||||||
|
import std.algorithm.mutation : copy;
|
||||||
import std.format;
|
import std.format;
|
||||||
iota(0, 5).map!(i => format("%s ", i)).copy(stdout.lockingTextWriter());
|
iota(0, 5).map!(i => format("%s ", i)).copy(stdout.lockingTextWriter());
|
||||||
writeln();
|
writeln();
|
||||||
|
|
|
@ -1078,7 +1078,7 @@ template hasMobileElements(R)
|
||||||
///
|
///
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : map;
|
import std.algorithm.iteration : map;
|
||||||
import std.range : iota, repeat;
|
import std.range : iota, repeat;
|
||||||
|
|
||||||
static struct HasPostblit
|
static struct HasPostblit
|
||||||
|
@ -1637,7 +1637,7 @@ auto walkLength(Range)(Range range, const size_t upTo)
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : filter;
|
import std.algorithm.iteration : filter;
|
||||||
import std.range : recurrence, take;
|
import std.range : recurrence, take;
|
||||||
|
|
||||||
//hasLength Range
|
//hasLength Range
|
||||||
|
@ -1760,7 +1760,7 @@ size_t popBackN(Range)(ref Range r, size_t n)
|
||||||
///
|
///
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : equal;
|
import std.algorithm.comparison : equal;
|
||||||
import std.range : iota;
|
import std.range : iota;
|
||||||
auto LL = iota(1L, 7L);
|
auto LL = iota(1L, 7L);
|
||||||
auto r = popFrontN(LL, 2);
|
auto r = popFrontN(LL, 2);
|
||||||
|
@ -1781,7 +1781,7 @@ size_t popBackN(Range)(ref Range r, size_t n)
|
||||||
///
|
///
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : equal;
|
import std.algorithm.comparison : equal;
|
||||||
import std.range : iota;
|
import std.range : iota;
|
||||||
auto LL = iota(1L, 7L);
|
auto LL = iota(1L, 7L);
|
||||||
auto r = popBackN(LL, 2);
|
auto r = popBackN(LL, 2);
|
||||||
|
@ -1841,7 +1841,8 @@ void popBackExactly(Range)(ref Range r, size_t n)
|
||||||
///
|
///
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm : filterBidirectional, equal;
|
import std.algorithm.iteration : filterBidirectional;
|
||||||
|
import std.algorithm.comparison : equal;
|
||||||
|
|
||||||
auto a = [1, 2, 3];
|
auto a = [1, 2, 3];
|
||||||
a.popFrontExactly(1);
|
a.popFrontExactly(1);
|
||||||
|
@ -2097,7 +2098,7 @@ version(unittest)
|
||||||
void popFront(C)(ref C[] str) @trusted pure nothrow
|
void popFront(C)(ref C[] str) @trusted pure nothrow
|
||||||
if (isNarrowString!(C[]))
|
if (isNarrowString!(C[]))
|
||||||
{
|
{
|
||||||
import std.algorithm : min;
|
import std.algorithm.comparison : min;
|
||||||
|
|
||||||
assert(str.length, "Attempting to popFront() past the end of an array of " ~ C.stringof);
|
assert(str.length, "Attempting to popFront() past the end of an array of " ~ C.stringof);
|
||||||
|
|
||||||
|
|
|
@ -2301,7 +2301,7 @@ public:
|
||||||
{
|
{
|
||||||
version (Windows)
|
version (Windows)
|
||||||
{
|
{
|
||||||
import std.algorithm : countUntil;
|
import std.algorithm.searching : countUntil;
|
||||||
auto fds = fds;
|
auto fds = fds;
|
||||||
auto p = fds.countUntil(s);
|
auto p = fds.countUntil(s);
|
||||||
if (p >= 0)
|
if (p >= 0)
|
||||||
|
|
|
@ -2328,7 +2328,7 @@ size_t codeLength(C, InputRange)(InputRange input)
|
||||||
{
|
{
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.exception;
|
import std.exception;
|
||||||
import std.algorithm : filter;
|
import std.algorithm.iteration : filter;
|
||||||
|
|
||||||
assertCTFEable!(
|
assertCTFEable!(
|
||||||
{
|
{
|
||||||
|
|
|
@ -703,7 +703,7 @@ public struct UUID
|
||||||
*/
|
*/
|
||||||
@safe pure nothrow @nogc int opCmp(in UUID s) const
|
@safe pure nothrow @nogc int opCmp(in UUID s) const
|
||||||
{
|
{
|
||||||
import std.algorithm : cmp;
|
import std.algorithm.comparison : cmp;
|
||||||
return cmp(this.data[], s.data[]);
|
return cmp(this.data[], s.data[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ public struct UUID
|
||||||
*/
|
*/
|
||||||
@safe pure nothrow @nogc int opCmp(ref in UUID s) const
|
@safe pure nothrow @nogc int opCmp(ref in UUID s) const
|
||||||
{
|
{
|
||||||
import std.algorithm : cmp;
|
import std.algorithm.comparison : cmp;
|
||||||
return cmp(this.data[], s.data[]);
|
return cmp(this.data[], s.data[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ unittest
|
||||||
{
|
{
|
||||||
import std.exception;
|
import std.exception;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.algorithm : startsWith, endsWith;
|
import std.algorithm.searching : startsWith, endsWith;
|
||||||
|
|
||||||
auto e = collectException!WindowsException(
|
auto e = collectException!WindowsException(
|
||||||
DeleteFileA("unexisting.txt").wenforce("DeleteFile")
|
DeleteFileA("unexisting.txt").wenforce("DeleteFile")
|
||||||
|
|
|
@ -287,7 +287,7 @@ final class ArchiveMember
|
||||||
final class ZipArchive
|
final class ZipArchive
|
||||||
{
|
{
|
||||||
import std.bitmanip : littleEndianToNative, nativeToLittleEndian;
|
import std.bitmanip : littleEndianToNative, nativeToLittleEndian;
|
||||||
import std.algorithm : max;
|
import std.algorithm.comparison : max;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.datetime : DosFileTime;
|
import std.datetime : DosFileTime;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
* import std.zlib;
|
* import std.zlib;
|
||||||
* import std.stdio;
|
* import std.stdio;
|
||||||
* import std.conv : to;
|
* import std.conv : to;
|
||||||
* import std.algorithm : map;
|
* import std.algorithm.iteration : map;
|
||||||
*
|
*
|
||||||
* UnCompress decmp = new UnCompress;
|
* UnCompress decmp = new UnCompress;
|
||||||
* foreach (chunk; stdin.byChunk(4096).map!(x => decmp.uncompress(x)))
|
* foreach (chunk; stdin.byChunk(4096).map!(x => decmp.uncompress(x)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue